Skip to content

Commit

Permalink
feat: base branch selection for OSS and IaC (#513)
Browse files Browse the repository at this point in the history
* feat: add base branch selection for other products

* chore: update changelog
  • Loading branch information
ShawkyZ authored Aug 21, 2024
1 parent a367a93 commit 5d76986
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Snyk Security Changelog

## [2.18.0]
- Added base branch selection for IaC and OSS

## [2.17.0]
- render IaC via Language Server

Expand Down
6 changes: 1 addition & 5 deletions src/snyk/common/views/issueTreeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,6 @@ export abstract class ProductIssueTreeProvider<T> extends AnalysisTreeNodeProvid
}

getBaseBranch(folderPath: string): TreeNode | undefined {
const isSnykCodeProduct = (this.productService as ProductService<T>).getSnykProductType() === ScanProduct.Code;
if (!isSnykCodeProduct) {
return;
}
const deltaFindingsEnabled = this.configuration.getDeltaFindingsEnabled();
const config = this.folderConfigs.getFolderConfig(this.configuration, folderPath);

Expand Down Expand Up @@ -318,7 +314,7 @@ export abstract class ProductIssueTreeProvider<T> extends AnalysisTreeNodeProvid
return nodes;
}

private addBaseBranchNode(baseBranchNode: TreeNode | undefined, nodes: TreeNode[]) {
addBaseBranchNode(baseBranchNode: TreeNode | undefined, nodes: TreeNode[]) {
if (!baseBranchNode) {
return;
}
Expand Down
7 changes: 7 additions & 0 deletions src/snyk/snykOss/providers/ossVulnerabilityTreeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,14 @@ export default class OssIssueTreeProvider extends ProductIssueTreeProvider<OssIs
continue;
}

const baseBranchNode = this.getBaseBranch(uri.fsPath);
if (folderVulnCount == 0) {
this.addBaseBranchNode(baseBranchNode, nodes);
continue;
}
// flatten results if single workspace folder
if (this.productService.result.size === 1) {
this.addBaseBranchNode(baseBranchNode, nodes);
nodes.push(...fileNodes);
} else {
const folderNode = new TreeNode({
Expand All @@ -138,6 +144,7 @@ export default class OssIssueTreeProvider extends ProductIssueTreeProvider<OssIs
severity: ProductIssueTreeProvider.getSeverityComparatorIndex(folderSeverity),
},
});
this.addBaseBranchNode(baseBranchNode, fileNodes);
nodes.push(folderNode);
}
}
Expand Down

0 comments on commit 5d76986

Please sign in to comment.