Skip to content

Commit

Permalink
[Integration][Synk] Update Snyk Integration with Improved Default Blu…
Browse files Browse the repository at this point in the history
…eprints (port-labs#676)
  • Loading branch information
phalbert authored Jun 25, 2024
1 parent 8bc44d7 commit 57037de
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 42 deletions.
53 changes: 21 additions & 32 deletions integrations/snyk/.port/resources/blueprints.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,7 @@
"icon": "Alert",
"title": "Issue Severity",
"type": "string",
"enum": [
"low",
"medium",
"high",
"critical"
],
"enum": ["low", "medium", "high", "critical"],
"enumColors": {
"low": "green",
"medium": "yellow",
Expand Down Expand Up @@ -98,7 +93,14 @@
},
"mirrorProperties": {},
"calculationProperties": {},
"relations": {}
"relations": {
"project": {
"title": "Project",
"target": "snykProject",
"required": false,
"many": false
}
}
},
{
"identifier": "snykProject",
Expand All @@ -112,12 +114,6 @@
"format": "url",
"icon": "Snyk"
},
"owner": {
"type": "string",
"title": "Owner",
"format": "user",
"icon": "TwoUsers"
},
"businessCriticality": {
"title": "Business Criticality",
"type": "array",
Expand Down Expand Up @@ -179,33 +175,26 @@
"type": "number",
"title": "Open Low Vulnerabilities"
},
"importedBy": {
"icon": "TwoUsers",
"type": "string",
"title": "Imported By",
"format": "user"
},
"tags": {
"type": "array",
"title": "Tags",
"icon": "DefaultProperty"
},
"targetOrigin": {
"type": "string",
"title": "Target Origin"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"aggregationProperties": {},
"relations": {
"snykVulnerabilities": {
"title": "Snyk Vulnerabilities",
"target": "snykVulnerability",
"snyk_target": {
"title": "Snyk Target",
"target": "snykTarget",
"required": false,
"many": true
},
"snykOrganization": {
"title": "Snyk Organization",
"target": "snykOrganization",
"required": true,
"many": false
}
}
Expand Down Expand Up @@ -278,11 +267,11 @@
"mirrorProperties": {},
"calculationProperties": {},
"relations": {
"snykProjects": {
"title": "Snyk Projects",
"target": "snykProject",
"synk_organization": {
"title": "Snyk Organization",
"target": "snykOrganization",
"required": false,
"many": true
"many": false
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions integrations/snyk/.port/resources/port-app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ resources:
language: .issueData.language // .issueType
publicationTime: .issueData.publicationTime
isPatched: .isPatched
relations:
project: '.links.paths | split("/") | .[8]'
- kind: project
selector:
query: 'true'
Expand All @@ -41,33 +43,31 @@ resources:
blueprint: '"snykProject"'
properties:
url: ("https://app.snyk.io/org/" + .relationships.organization.data.id + "/project/" + .id | tostring)
owner: .__owner.email
businessCriticality: .attributes.business_criticality
environment: .attributes.environment
lifeCycle: .attributes.lifecycle
highOpenVulnerabilities: .meta.latest_issue_counts.high
mediumOpenVulnerabilities: .meta.latest_issue_counts.medium
lowOpenVulnerabilities: .meta.latest_issue_counts.low
criticalOpenVulnerabilities: .meta.latest_issue_counts.critical
importedBy: .__importer.email
tags: .attributes.tags
targetOrigin: .origin
relations:
snykVulnerabilities: '[.__issues[] | select(.issueType == "vuln").issueData.id]'
snykOrganization: .relationships.organization.data.id
snyk_target: '.relationships.target.data.id'
- kind: target
selector:
query: 'true'
port:
entity:
mappings:
identifier: .attributes.displayName
title: .attributes.displayName
identifier: .id
title: .attributes.display_name
blueprint: '"snykTarget"'
properties:
origin: .attributes.origin
origin: .relationships.integration.data.attributes.integration_type
highOpenVulnerabilities: '[.__projects[].meta.latest_issue_counts.high] | add'
mediumOpenVulnerabilities: '[.__projects[].meta.latest_issue_counts.medium] | add'
lowOpenVulnerabilities: '[.__projects[].meta.latest_issue_counts.low] | add'
criticalOpenVulnerabilities: '[.__projects[].meta.latest_issue_counts.critical] | add'
relations:
snykProjects: '[.__projects[].id]'
synk_organization: '.relationships.organization.data.id'
8 changes: 8 additions & 0 deletions integrations/snyk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- towncrier release notes start -->

# Port_Ocean 0.1.61 (2024-06-25)

### Improvements

- Utilizing the latest Targets API (2024-05-23~beta): Updated the integration to leverage the latest version of Snyk's Targets API. This change is crucial because it introduces a relationships attribute, containing the essential organisation id needed to accurately link each target to its parent organization. (#1)
- Updated the default blueprints to the following structure: Vuln -> Project -> Target -> Organization.


# Port_Ocean 0.1.60 (2024-06-23)

### Improvements
Expand Down
2 changes: 1 addition & 1 deletion integrations/snyk/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "snyk"
version = "0.1.60"
version = "0.1.61"
description = "Snyk integration powered by Ocean"
authors = ["Isaac Coffie <[email protected]>"]

Expand Down
3 changes: 2 additions & 1 deletion integrations/snyk/snyk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ async def get_paginated_targets(
logger.info(f"Fetching paginated targets for organization: {org['id']}")

url = f"/orgs/{org['id']}/targets"
query_params = {"version": f"{self.snyk_api_version}~beta"}
target_api_version = "2024-05-23"
query_params = {"version": f"{target_api_version}~beta"}
async for targets in self._get_paginated_resources(
url_path=url, query_params=query_params
):
Expand Down

0 comments on commit 57037de

Please sign in to comment.