See also Best practices for tips on how to optimize queries.
Get list of projects
Add one or more field-masks to limit the fields returned for each object. For example, set the field-mask to meta.name to only get the name and UUID of all projects. The UUID is always returned.
Get project UUID
The project UUID connects all the objects for a given project. One way to get the project UUID is to extract it from the uuid field in the Project object. For more information, see Resource kinds.
Get list of findings for a project
Use the following filter to get a list of findings for a given project:
spec.project_uuid==<project-uuid>
Get number of findings for a project
Add the --count flag to just get the number of findings. This is much faster than retrieving the objects.
Get number of findings for a project by severity
Use grouping to get the number of findings by severity.
Get list of findings for reachable functions
Use the following filter to get a list of findings for reachable functions:
spec.finding_tags contains FINDING_TAGS_REACHABLE_FUNCTION
For a list of all finding attributes, see Finding tags.
Get list of findings for reachable functions for a project
Combine the previous filters to get a list of findings for reachable functions for a given project:
spec.project_uuid==<project-uuid> and spec.finding_tags contains FINDING_TAGS_REACHABLE_FUNCTION
Get list of findings in a category
Use the following filter to get a list of findings in the RSPM category:
spec.finding_categories contains FINDING_CATEGORY_SCPM
For a list of all finding categories, see Finding categories.
Get list of findings for a vulnerability
Use the following filter to get a list of findings for a given vulnerability, for example "CVE-2024-53677" or "GHSA-43mq-6xmg-29vm":
spec.finding_metadata.vulnerability.spec.aliases contains CVE-2024-53677
Note: You can replace the CVE ID in the example with any other vulnerability ID type, such as GHSA, BIT, GO, PYSEC, or OVAL.
Get list of findings for a code owner
Use the spec.code_owners.owners field to filter findings based on code owner.
Note: Code owners are automatically assigned based on the CodeOwners object for the project, which Endor Labs generates from the CODEOWNERS file in the default branch. For projects without a CODEOWNERS file, manage the CodeOwners object through the API.
Group findings by code owner
Use the spec.code_owners.owners field to group findings based on code owner.
Note: Code owners are automatically assigned based on the CodeOwners object for the project, which Endor Labs generates from the CODEOWNERS file in the default branch. For projects without a CODEOWNERS file, manage the CodeOwners object through the API.
Get finding snooze history
Endor Labs captures snooze updates as FindingLog objects.
Get Endor Labs scores for an OSS package
-
Set the namespace to
"oss" because the OSS tenant stores data for OSS packages.
-
Endor Labs stores package version scores in the
"package_version_scorecard" Metric object, in the spec.metric_values.scorecard.score_card.category_scores field, so you need to get this Metric object for the given OSS package. For more information, see the Metric resource kind documentation.
-
To get Metric objects belonging to a given package version, get the UUID of the corresponding PackageVersion object. The PackageVersion object name must be in the format
<ecosystem>://<name>@<version>, for example: "mvn://ch.qos.logback:logback-core@1.3.3". For more information, see the PackageVersion resource kind documentation. Once you have the PackageVersion object, use the following jq command to extract the UUID:
jq '.list.object[].uuid'
-
Get the Metric object corresponding to the PackageVersion UUID using the following two filters:
meta.name==package_version_scorecard
meta.parent_uuid==<package-version-uuid>
-
Use the following
jq command to extract just the Endor Labs scores from the Metric object:
jq '.list.objects[].spec.metric_values.scorecard.score_card.category_scores'
Below is an example response to the request.
Get license text from a license finding
-
Look up a license-related Finding object for a dependency using the following filter:
spec.finding_categories contains [FINDING_CATEGORY_LICENSE_RISK] and spec.finding_tags not contains [FINDING_TAGS_SELF]
-
Get the name of the corresponding PackageVersion object from the
spec.target_dependency_package_name field. If we have a list of Finding objects, we can use the following jq command to get the PackageVersion name:
jq '.list.objects[].spec.target_dependency_package_name'
-
Look up the PackageVersion object and store the UUID.
Note: If this is an OSS dependency we must use the “oss” namespace.
-
Look up the corresponding
pkg_version_info_for_license Metric object using the following filter:
meta.name==pkg_version_info_for_license&meta.parent_uuid==$UUID
Note: The Metric is in the same namespace as the PackageVersion.
-
Use the following
jq command to extract the license text from the Metric object:
jq '.list.objects[].spec.metric_values.licenseInfoType.license_info.all_licenses[].matched_text'
For more information, see the Metric resource kind documentation.
-
Endor Labs stores CI/CD tool metrics in the
version_cicd_tools Metric object, in the spec.metric_values.CiCdTools.ci_cd_tools.tools list. Use the following filter to get all such Metrics with entries for the given tool name (GitHub Actions in this example). For more information, see the Metric resource kind documentation.
meta.name==version_cicd_tools and spec.metric_values.CiCdTools.ci_cd_tools.tools.name=='GitHub Actions'
-
Use the following
jq command to get the UUIDs of the corresponding Project objects:
.list.objects[].spec.project_uuid
-
Remove duplicate Project UUIDs (a Project can have multiple repository versions).
-
Use the UUIDs to get the corresponding Project objects.
See also List Projects, with Repository Versions and CI/CD Tool Metrics for a Query Service example that retrieves CI/CD tool Metrics for a list of projects.
Get the latest scan result
-
To get the latest object, first sort the objects in descending order, based on the
meta.create_time field:
list_parameters.sort.order=SORT_ENTRY_ORDER_DESC&list_parameters.sort.path=meta.create_time
-
Then, to get only the latest object, set the page size to 1:
list_parameters.page_size=1
Create a policy
The following example uses the Create Policy endpoint to create a new policy.
Update a policy to include a project
The following example uses the Update Policy endpoint to apply a policy to a given project by updating the spec.project_selector tag list.
This overrides the existing project_selector list, so you must pass in all the project inclusion tags that you want to keep for this policy along with the new tag.
Update a policy to exclude a project
The following example uses the Update Policy endpoint to exclude a given project from a policy by updating the spec.project_exceptions tag list.
This overrides the existing project_exceptions list, so you must pass in all project exception tags that you want to keep for this policy along with the new tag.
The following example uses the Update Policy endpoint to specify a list of custom tags to apply to findings matching a given exception policy.
This overrides the existing spec.exception.tags list, so you must pass in all tags that you want to keep for this policy along with the new tag.
Upgrade a policy to use the latest template version
The following example uses the Update Policy endpoint to upgrade a given policy to use the latest template version.
Delete a policy
The following example uses the Delete Policy endpoint to delete a policy.
The following example uses the Update Finding endpoint to add custom tags to a finding by updating the meta.tags field.
This overrides the existing meta.tags list, so you must pass in all tags that you want to keep for this object along with the new tag.
Get data from child namespaces
Use the traverse option to include data from child namespaces as well as the parent namespace.