Skip to content

Commit

Permalink
v1.10.1 - export-file option (#25)
Browse files Browse the repository at this point in the history
* v1.10.0 - export-file option

* v1.10.1

* v1.10.1 - fix sarif file export
  • Loading branch information
davidknise committed Oct 31, 2023
1 parent 8680376 commit b936959
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microsoft/security-devops-azdevops-task-lib",
"version": "1.9.0",
"version": "1.10.1",
"description": "Microsoft Security DevOps for Azure DevOps task library.",
"author": "Microsoft Corporation",
"license": "MIT",
Expand Down
10 changes: 9 additions & 1 deletion src/msdo-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,15 @@ export async function run(inputArgs: string[], successfulExitCodes: number[] = n
// Write it as an environment variable for follow up tasks to consume
tl.setVariable('MSDO_SARIF_FILE', sarifFile);

tool.arg('--export-breaking-results-to-file');
if (common.isVersionGreaterThanOrEqualTo(process.env.MSDO_INSTALLEDVERSION, '0.183.0')) {
// Export all SARIF results to a file
tool.arg('--export-file');
} else {
// This still exists, but the behavior was corrected in 0.183.0
// This defaults to only exporting breaking results, as the name implies
tool.arg('--export-breaking-results-to-file');
}

tool.arg(sarifFile);

tool.arg('--telemetry-environment');
Expand Down
37 changes: 37 additions & 0 deletions src/msdo-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,41 @@ export function getMsdoBreakEnvironmentVariable() : boolean {
*/
export function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

/**
* Lazy checks if the version1 is greater than or equal to version2.
*
* @param version1 The version to check.
* @param version2 The version to compare against.
* @returns True if the version is greater than or equal to version2, or true in any error condition.
*/
export function isVersionGreaterThanOrEqualTo(version1: string, version2: string): boolean {
if (version1 == null || version2 == null) {
return true;
}

let version1Parts = version1.split('.');
let version2Parts = version2.split('.');

if (version1Parts == null || version2Parts == null) {
return true;
}

let version1Part = 0;
let version2Part = 0;

for (let i = 0; i < version1Parts.length; i++) {
version1Part = parseInt(version1Parts[i] || '0');
version2Part = parseInt(version2Parts[i] || '0');

if (version1Part > version2Part) {
return true;
}
else if (version1Part < version2Part) {
return false;
}
}

return true;
}
1 change: 1 addition & 0 deletions src/msdo-installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ function setVariables(

process.env.MSDO_DIRECTORY = msdoDirectory;
process.env.MSDO_FILEPATH = msdoFilePath;
process.env.MSDO_INSTALLEDVERSION = cliVersion;

let exists = fs.existsSync(process.env.MSDO_FILEPATH);

Expand Down

0 comments on commit b936959

Please sign in to comment.