Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.1.x - Blocked / Waiting #14

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion finite_state_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,34 @@ def create_asset(token, organization_context, business_unit_id=None, created_by_
response = send_graphql_query(token, organization_context, graphql_query, variables)
return response['data']

"""
Call updateAsset to set the defaultVersion to the newly created AssetVersion
"""
def update_asset(token, organization_context, asset_id, asset_version_id):
graphql_query = '''
mutation UpdateAssetMutation($input: UpdateAssetInput!) {
updateAsset(input: $input) {
id
name
defaultVersion {
id
}
versions {
id
}
}
}
'''

variables = {
"input": {
"id": asset_id,
"defaultVersion": asset_version_id
}
}

response = send_graphql_query(token, organization_context, graphql_query, variables)
return response['data']

def create_asset_version(token, organization_context, business_unit_id=None, created_by_user_id=None, asset_id=None, asset_version_name=None, product_id=None):
"""
Expand Down Expand Up @@ -246,6 +274,11 @@ def create_asset_version(token, organization_context, business_unit_id=None, cre
variables["input"]["ctx"]["products"] = product_id

response = send_graphql_query(token, organization_context, graphql_query, variables)

if response.ok:
asset_version_id = response['data']['createAssetVersion']['id']
update_asset(token, organization_context, asset_id, asset_version_id)

return response['data']


Expand Down Expand Up @@ -1251,7 +1284,8 @@ def get_findings(token, organization_context, asset_version_id=None, category=No
asset_version_id (str, optional):
Asset Version ID to get findings for. If not provided, will get all findings in the organization.
category (str, optional):
The category of Findings to return. Valid values are "CONFIG_ISSUES", "CREDENTIALS", "CRYPTO_MATERIAL", "CVE", "SAST_ANALYSIS". If not specified, will return all findings. See https://docs.finitestate.io/types/finding-category
The category of Findings to return. Valid values are "CONFIG_ISSUES", "CREDENTIALS", "CRYPTO_MATERIAL", "CVE", "SAST_ANALYSIS". If not specified, will return all findings. See https://docs.finitestate.io/types/finding-category.
This can be a single string, or an array of values.
status (str, optional):
The status of Findings to return.
severity (str, optional):
Expand Down
8 changes: 5 additions & 3 deletions finite_state_sdk/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,14 +376,16 @@ def _create_GET_FINDINGS_VARIABLES(asset_version_id=None, category=None, cve_id=
else:
variables["filter"]["assetVersionRefId"] = str(asset_version_id)

# if category is a string, make it a list
if isinstance(category, str):
category = [category]

if category is not None:
variables["filter"]["AND"] = [
{
"OR": [
{
"category_in": [
category
]
"category_in": category
}
]
},
Expand Down