-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathmsdo.ts
More file actions
91 lines (77 loc) · 3.08 KB
/
Copy pathmsdo.ts
File metadata and controls
91 lines (77 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import * as core from '@actions/core';
import { IMicrosoftSecurityDevOps } from './msdo-interface';
import { Tools } from './msdo-helpers';
import * as client from '@microsoft/security-devops-actions-toolkit/msdo-client';
import * as common from '@microsoft/security-devops-actions-toolkit/msdo-common';
/*
* Microsoft Security DevOps analyzers runner.
*/
export class MicrosoftSecurityDevOps implements IMicrosoftSecurityDevOps {
readonly succeedOnError: boolean;
constructor() {
this.succeedOnError = false;
}
public async runPreJob() {
// No pre-job commands yet
}
public async runPostJob() {
// No post-job commands yet
}
public async runMain() {
core.debug('MicrosoftSecurityDevOps.runMain - Running MSDO...');
let args: string[] = ['run'];
let config: string = core.getInput('config');
if (!common.isNullOrWhiteSpace(config)) {
args.push('-c');
args.push(config);
}
let policy: string = core.getInput('policy');
if (common.isNullOrWhiteSpace(policy)) {
policy = "GitHub";
}
args.push('-p');
args.push(policy);
let categoriesString: string = core.getInput('categories');
if (!common.isNullOrWhiteSpace(categoriesString)) {
args.push('--categories');
let categories = categoriesString.split(',');
for (let i = 0; i < categories.length; i++) {
let category = categories[i];
if (!common.isNullOrWhiteSpace(category)) {
args.push(category.trim());
}
}
}
let languagesString: string = core.getInput('languages');
if (!common.isNullOrWhiteSpace(languagesString)) {
args.push('--languages');
let languages = languagesString.split(',');
for (let i = 0; i < languages.length; i++) {
let language = languages[i];
if (!common.isNullOrWhiteSpace(language)) {
args.push(language.trim());
}
}
}
let toolsString: string = core.getInput('tools');
let includedTools = [];
if (!common.isNullOrWhiteSpace(toolsString)) {
let tools = toolsString.split(',');
for (let i = 0; i < tools.length; i++) {
let tool = tools[i];
let toolTrimmed = tool.trim();
if (!common.isNullOrWhiteSpace(tool)
&& tool != Tools.ContainerMapping // This tool is not handled by this executor
&& includedTools.indexOf(toolTrimmed) == -1) {
if (includedTools.length == 0) {
args.push('--tool');
}
args.push(toolTrimmed);
includedTools.push(toolTrimmed);
}
}
}
args.push('--github');
await client.run(args, 'microsoft/security-devops-action');
}
}