Skip to content

Commit f476bf7

Browse files
authored
v1.9.1 - export-file (#15)
* v1.9.0 - export-file * v1.9.1 - correct sarif file export * v1.9.1 - Update package-lock.json
1 parent 9a86f5a commit f476bf7

File tree

5 files changed

+50
-4
lines changed

5 files changed

+50
-4
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@microsoft/security-devops-actions-toolkit",
3-
"version": "1.8.2",
3+
"version": "1.9.1",
44
"description": "Microsoft Security DevOps for GitHub Actions toolkit.",
55
"author": "Microsoft Corporation",
66
"license": "MIT",

src/msdo-client.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,15 @@ export async function run(inputArgs: string[], telemetryEnvironment: string = 'g
129129
core.exportVariable('MSDO_SARIF_FILE', sarifFile);
130130
core.setOutput('sarifFile', sarifFile);
131131

132-
args.push('--export-breaking-results-to-file');
132+
if (common.isVersionGreaterThanOrEqualTo(process.env.MSDO_INSTALLEDVERSION, '0.183.0')) {
133+
// Export all SARIF results to a file
134+
args.push('--export-file');
135+
} else {
136+
// This still exists, but the behavior was corrected in 0.183.0
137+
// This defaults to only exporting breaking results, as the name implies
138+
args.push('--export-breaking-results-to-file');
139+
}
140+
133141
args.push(sarifFile);
134142

135143
args.push('--telemetry-environment');

src/msdo-common.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,41 @@ export function getMsdoBreakEnvironmentVariable() : boolean {
144144
*/
145145
export function sleep(ms) {
146146
return new Promise(resolve => setTimeout(resolve, ms));
147+
}
148+
149+
/**
150+
* Lazy checks if the version1 is greater than or equal to version2.
151+
*
152+
* @param version1 The version to check.
153+
* @param version2 The version to compare against.
154+
* @returns True if the version is greater than or equal to version2, or true in any error condition.
155+
*/
156+
export function isVersionGreaterThanOrEqualTo(version1: string, version2: string): boolean {
157+
if (version1 == null || version2 == null) {
158+
return true;
159+
}
160+
161+
let version1Parts = version1.split('.');
162+
let version2Parts = version2.split('.');
163+
164+
if (version1Parts == null || version2Parts == null) {
165+
return true;
166+
}
167+
168+
let version1Part = 0;
169+
let version2Part = 0;
170+
171+
for (let i = 0; i < version1Parts.length; i++) {
172+
version1Part = parseInt(version1Parts[i] || '0');
173+
version2Part = parseInt(version2Parts[i] || '0');
174+
175+
if (version1Part > version2Part) {
176+
return true;
177+
}
178+
else if (version1Part < version2Part) {
179+
return false;
180+
}
181+
}
182+
183+
return true;
147184
}

src/msdo-installer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ function setVariables(
167167

168168
process.env.MSDO_DIRECTORY = msdoDirectory;
169169
process.env.MSDO_FILEPATH = msdoFilePath;
170+
process.env.MSDO_INSTALLEDVERSION = cliVersion;
170171

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

0 commit comments

Comments
 (0)