Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.10.1 - export-file option #25

Merged
merged 3 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')) {
davidknise marked this conversation as resolved.
Show resolved Hide resolved
// 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
Loading