IBM Guardium

IBM Guardium

Join this online user group to communicate across Security product users and IBM experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Datasource definitions

    Posted 02/11/20 05:20 PM
    Hi - I'm new to the group and hoping someone has figured this out! I need to create datasource definitions for all the databases on a bunch of oracle servers. Do I really have to create each of these one by one or is there a script I can run to automate this? We are on version 11.0.
    Thanks for your help.

    ------------------------------
    Carolyn
    ------------------------------


  • 2.  RE: Datasource definitions

    Posted 02/12/20 02:30 AM
    With grdapi you should create script or manage datasource creation by REST interface

    grdapi create_datasource --help=true
    ID=0
    available since version:
    v9.5
    function parameters:
    application - String- required- Constant values list
    clusterName - String
    compatibilityMode - String
    conProperty - String
    customURL - String
    cyberarkConfigName - String- Constant values list
    cyberarkObjectName - String
    dbInstanceAccount - String
    dbInstanceDirectory - String
    dbName - String
    description - String
    externalPasswordTypeName - String- Constant values list
    host - String- required
    importServerSSLcert - Boolean
    KerberosConfigName - String
    name - String- required
    password - String
    port - Integer
    savePassword - Boolean
    serviceName - String
    severity - String- Constant values list
    shared - String- Constant values list
    type - String- required- Constant values list
    useExternalPassword - Boolean
    useKerberos - Boolean
    useLDAP - Boolean
    user - String
    useSSL - Boolean

    ------------------------------
    Zbigniew Szmigiero
    IBM
    Warsaw
    ------------------------------



  • 3.  RE: Datasource definitions

    Posted 02/12/20 02:08 PM
    Thanks Zbigniew. I've been combing thru the guard API & REST documentation.

    ------------------------------
    Carolyn Curtis
    ------------------------------



  • 4.  RE: Datasource definitions
    Best Answer

    Posted 02/12/20 10:59 AM
      |   view attached
    There are two ways to import data sources to Guardium, and automate the process:

    1 - Data sources, if maintained in a CSV file can be uploaded in bulk to the system. I attached a CSV example, here is how you upload the file.  From the GUI, navigate to Harden | Vulnerability Assessment | Customer Uploads and select "Upload CSV to Create/Update Datasources".  Sample file attached.

    2 - REST API
    REST Call Example:

    Step 1:
    Register the Client in the CLI

    CLI> grdapi register_oauth_client client_id=ABC grant_types=password
    ID=0
    {"client_id":"ABC","client_secret":"3b68f4d8-bb2f-4722-a49c-678bdc3507ab","grant_types":"password","scope":"read,write","redirect_uri":"https://someApp"}


    Step 2:
    Obtain a token (from any machine that can access the Guardium machine) using the client secret and client Id from Step1:

    curl -k -X POST -d 'client_id=ABC&grant_type=password&client_secret=3b68f4d8-bb2f-4722-a49c-678bdc3507ab&username=USER&password=PASSWORD' https://GuardiumMachine.Company.com:8443/oauth/token
    {"access_token":"acb1bc03-a59d-48b3-a649-b7db09d7ac97","token_type":"bearer","expires_in":9684,"scope":"read write"}

    Step 3
    : Your REST Call using the token obtained in Step2. This example calls a create datasource:
    curl -k --header "Authorization:Bearer acb1bc03-a59d-48b3-a649-b7db09d7ac97" -i -H "Content-Type:application/json" -X POST -d '{"application":"Security Assessment", "description":"MyDataSourceDescription","name":"MyDataSourceName", "host":"my_host.myCompany.com", "type":"DB2", "serviceName":"servName", "user":"myUser","password":"PASSWD"}' https://GuardiumMachine.Company.com:8443/restAPI/datasource

    HTTP/1.1 200 OK
    X-FRAME-OPTIONS: SAMEORIGIN
    X-Permitted-Cross-Domain-Policies: none
    X-Content-Type-Options: nosniff
    X-XSS-Protection: 1; mode=block
    Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://ibm.biz/GuardiumUpdateCheck https://ibm.biz/GuardiumUpdateCheckQA https://*.ibm.com; img-src 'self' data: https://*.ibm.com; connect-src 'self'; frame-src 'self' https:; style-src 'self' https: 'unsafe-inline'; font-src 'self' https: 'unsafe-inline'
    Strict-Transport-Security: max-age=31536000
    Set-Cookie: JSESSIONID=25431BA26CD45EF3C4FF1A767261D5D3; Path=/; Secure; HttpOnly
    Cache-Control: max-age=86400
    Expires: Fri, 08 Mar 2019 20:40:41 GMT
    Access-Control-Allow-Methods: POST, GET, PUT, DELETE
    Access-Control-Allow-Headers: authorization, origin, X-Requested-With, Content-Type, Accept
    Access-Control-Max-Age: 18000
    Content-Type: application/json;charset=UTF-8
    Content-Length: 35
    Date: Thu, 07 Mar 2019 20:40:41 GMT
    Server: SQL Guard

    {
    "ID": 20002,
    "Message": ""
    }

    Note:
    I provided only the required parameters, this specific call allows for more detailed datasource creation, to see all parameters from the CLI:
    CLI> guardapi create_datasource --help=true
    grdapi create_datasource --help=true
    ID=0
    available since version:
    v9.5
    function parameters:
    application - String- required- Constant values list
    compatibilityMode - String
    conProperty - String
    customURL - String
    cyberarkConfigName - String- Constant values list
    cyberarkObjectName - String
    dbInstanceAccount - String
    dbInstanceDirectory - String
    dbName - String
    description - String
    externalPasswordTypeName - String- Constant values list
    host - String- required
    importServerSSLcert - Boolean
    KerberosConfigName - String
    name - String- required
    password - String
    port - Integer
    savePassword - Boolean
    serviceName - String
    severity - String- Constant values list
    shared - String- Constant values list
    type - String- required- Constant values list
    useExternalPassword - Boolean
    useKerberos - Boolean
    useLDAP - Boolean
    user - String
    useSSL - Boolean

    To get a Constant values list for a parameter, call the function with --get_param_values=<param-name>

    ------------------------------
    Dan Price
    ------------------------------

    Attachment(s)



  • 5.  RE: Datasource definitions

    Posted 02/12/20 02:25 PM
    Hi Dan. I have the command line format correct but my next question was how do I create a bunch of datasources at once. You answered that. Thanks for sharing the csv file. It's very helpful. 
    Appreciate the help everyone!

    carolyn

    ------------------------------
    Carolyn Curtis
    ------------------------------



  • 6.  RE: Datasource definitions

    Posted 02/17/20 10:03 AM
    Hi Dan - this is working fine except it won't save the user and password for authentication. There are radio buttons for authentication and it adds the datasource as None. I can't find the parameter to set it to Authenticate. Do you know what the name of it is?
    Thanks.

    ------------------------------
    Carolyn Curtis
    ------------------------------



  • 7.  RE: Datasource definitions

    Posted 03/01/20 06:28 AM
    Edited by Zbigniew (Zibi) Szmigiero 03/01/20 06:32 AM

    Hi, here this same programmatic way (python):

    Here simple example how to use GDP REST API programmatic way:
    1 - client registration
    from pexpect import pxssh
    client_id = 'pygdp'
    s = pxssh.pxssh(timeout=10)
    s.PROMPT = r'>'
    if not s.login ('cmp', 'cli', '<password>', auto_prompt_reset=False, original_prompt=r'>'):
    print("SSH session failed on login.")
    print(s)
    else:
    s.sendline ('grdapi register_oauth_client client_id=pygdp grant_types=password')
    # grdapi revokeOAuthClient client_id=pygdp
    s.prompt() # match the prompt
    output = s.before
    s.logout()
    print(output.decode("utf-8"))
    Result:
    <register_oauth_client client_id=pygdp grant_types=password
    ID=0
    {"client_id":"pygdp","client_secret":"337a6556-64b1-40db-ba56-01e5eef2778d","grant_types":"password","scope":"read,write","redirect_uri":"}
    ok
    cmp.guardium.notesProcess finished with exit code 0
    2) How to obtain token
    import requestsclient_id = 'pygdp'
    client_secret = '061722d4-915b-47e4-8c66-4a63c6ffe999'
    user = 'admin'
    password = '<password>'task = {"client_id": client_id, "client_secret": client_secret, "grant_type": "password", "username": user, "password": password}
    resp = requests.post('https://cmp.guardium.notes:8443/oauth/token' , verify=False, data=task)
    print(resp.text)
    Result:
    /home/zszmigiero/workspace/gapi/venv/bin/python /home/zszmigiero/workspace/gapi/get_token.py
    /home/zszmigiero/workspace/gapi/venv/lib64/python3.6/site-packages/urllib3/connectionpool.py:1004: InsecureRequestWarning: Unverified HTTPS request is being made to host 'cmp.guardium.notes'. Adding certificate verification is strongly advised. See:
    InsecureRequestWarning,
    {"access_token":"7b34c148-b30c-495e-ad05-38e2e41fdb6a","token_type":"bearer","expires_in":6697,"scope":"read write"}
    Process finished with exit code 0
    3) API call
    import requests
    token = '7b34c148-b30c-495e-ad05-38e2e41fdb6a'
    headers = {"Authorization": "Bearer {}".format(token), "Content-Type": "application/json"}
    resp = requests.get('https://cmp.guardium.notes:8443/restAPI/datasource?id=20000', verify=False, headers=headers)
    print(resp.text)
    Result:
    /home/zszmigiero/workspace/gapi/venv/bin/python /home/zszmigiero/workspace/gapi/api_call.py
    /home/zszmigiero/workspace/gapi/venv/lib64/python3.6/site-packages/urllib3/connectionpool.py:1004: InsecureRequestWarning: Unverified HTTPS request is being made to host 'cmp.guardium.notes'. Adding certificate verification is strongly advised. See: InsecureRequestWarning,[
    {
    "DatasourceId": "https://cmp.guardium.notes:8443/restAPI/datasource?id=20000",
    "DatasourceTypeId": "7",
    "Name": "aa",
    "Description": "",
    "Host": "coll1n",
    "Port": "0",
    "ServiceName": "",
    "UserName": "NA",
    "Password": "[B@ef2c4bf7",
    "PasswordStored": "true",
    "DbName": "",
    "LastConnect": "2019-04-20 08:29:58.0",
    "Timestamp": "2019-04-20 08:29:58.0",
    "ApplicationId": "47",
    "Shared": "false",
    "ConProperty": "",
    "OsUsername": "",
    "DbHomeDir": "",
    "CustomUrl": "",
    "Severity": "2",
    "DbDriverId": "7",
    "CompatibilityMode": "",
    "UseSsl": "false",
    "ImportServerSslCertificate": "false",
    "CertUniqueKey": "",
    "UseKerberos": "false",
    "KerberosConfigId": "0",
    "UseLdap": "false",
    "CyberarkConfigId": "0",
    "UseExternalPassword": "false",
    "CyberarkObjectName": "",
    "ExternalPasswordTypeId": "0",
    "externalPasswordType": "",
    "cyberarkConfig": "",
    "DatasourceType": "TEXT",
    "ApplicationType": "Custom Domain"
    }
    ]
    Process finished with exit code 0


    ------------------------------
    Zbigniew (Zibi) Szmigiero
    IBM
    Warsaw
    ------------------------------



  • 8.  RE: Datasource definitions

    Posted 02/12/20 10:59 AM

    Check out:

    Harden > Vulnerability Assessment > Customer Uploads

    There should be an area called "Upload CSV to Create/Update Datasources"

    Instructions and details on the data format it's expecting can be found here under the title "Create Datasource for CSV uploaded via the Upload CSV menu"

    https://www.ibm.com/support/knowledgecenter/SSMPHH_10.1.0/com.ibm.guardium.doc.admin/adm/subscribed_groups_upload.html



    ------------------------------
    John Haldeman
    ------------------------------