Skip to content

Commit

Permalink
fix: send additional report options to analyzeFolders
Browse files Browse the repository at this point in the history
  • Loading branch information
novalex committed Apr 4, 2023
1 parent e7ada14 commit f9eaf43
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib/plugins/sast/analysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ async function getCodeAnalysis(
reportOptions: {
enabled: options.report ?? false,
projectName: options['project-name'],
targetName: options['target-name'],
targetRef: options['target-reference'],
remoteRepoUrl: options['remote-repo-url'],
},
}),
analysisContext: {
Expand Down
21 changes: 21 additions & 0 deletions test/jest/unit/snyk-code/snyk-code-test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,13 @@ describe('Test snyk code', () => {
localCodeEngine: { url: '', allowCloudUpload: true, enabled: false },
};

const reportOptions = {
projectName: 'test-project-name',
targetName: 'test-target-name',
targetRef: 'test-target-ref',
remoteRepoUrl: 'https://github.com/owner/repo',
};

analyzeFoldersMock.mockResolvedValue(
sampleAnalyzeFoldersWithReportAndIgnoresResponse,
);
Expand All @@ -837,11 +844,25 @@ describe('Test snyk code', () => {
{
path: '',
code: true,
report: true,
'project-name': reportOptions.projectName,
'target-name': reportOptions.targetName,
'target-reference': reportOptions.targetRef,
'remote-repo-url': reportOptions.remoteRepoUrl,
},
sastSettings,
'test-id',
);

expect(analyzeFoldersMock).toHaveBeenCalledWith(
expect.objectContaining({
reportOptions: {
enabled: true,
...reportOptions,
},
}),
);

const expectedReportResults = {
projectId: 'test-project-id',
snapshotId: 'test-snapshot-id',
Expand Down

0 comments on commit f9eaf43

Please sign in to comment.