Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
minLevel1
maxLevel7

...

  • Navigate to required section. EEg. g Company as below to GET Company ID.

  • Description: String, skip, limit, sort

  1. String: Filter query to be executed against the database.

  2. Skip: It specifies the number of pages to skip.
    Eg: when the skip is set to 0 and the limit is set to 10, it will process the entire dataset by splitting it into 10 pages. The data from the first page will be returned, and for the second page, the skip will be 1, and the limit will be 10, returning the next 10 data.

  3. Limit: It limits the number of returned values. The default limit is 100.

  4. Sort: It specifies the sorting order based on the 'severity.keyword' field in descending order.

...

  • Refer to the Sample Script to get vulnerability, refer below example.

    Code Block
    import json
    Code Block
    sess_cookie = api.get_cookie()
    
    
    
    def get_vulns(sess_cookie, params, limit, skip=0):
        resp = requests.get(
            "https://portaluswest2.mycybercns.com/api/vulnerability/",
            headers={
                "content-type": "application/json"
            },
            params={"q": json.dumps(params), "limit": limit, "skip": skip},
            cookies=sess_cookie,
        )
        return resp.json()
    params = {
        "query": {
            "bool": {
                "must":
                [
                    {
                        "match": {
                            "severity.keyword": "High"
                        },
                    }
                ],
            }
        }
    }
    # dict_keys(['data', 'total', 'count', 'scroll_id'])
    vulns = get_vulns(sess_cookie, params, 5, 0)
    print(params["query"]["bool"]["must"][0]['match'])
    Code Block
    print(f"Total: {vulns['total']}")

...

{"query": {"bool": {"must": [{"exists": {"field": "host.importance"}}, {"match": {"companyRef.id.keyword": "bab8d50a-4f59-4c9b-bcab-303650facd24"}}], "must_not": [{"match": {"isdeprecated": true}}]}}}

...