Skip to content

WIP: feat: add in use flag #62

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ inputs:
description: 'Path to the IaC files to scan.'
required: false
default: "./"
in-use-file-path:
description: 'Path to the in-use file.'
required: false
default: "./in_use.txt"

outputs:
scanReport:
description: Path to a JSON file containing the report results, failed evaluation gates, and found vulnerabilities.
Expand Down
11 changes: 11 additions & 0 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface ActionInputParameters {
recursive: boolean;
minimumSeverity: string;
iacScanPath: string;
inUseFilePath: string;
}

export class ActionInputs {
Expand Down Expand Up @@ -77,6 +78,7 @@ export class ActionInputs {
recursive: core.getInput('recursive') == 'true',
minimumSeverity: core.getInput('minimum-severity'),
iacScanPath: core.getInput('iac-scan-path') || './',
inUseFilePath: core.getInput('in-use-file-path') || './in-use.txt',
};

const overridenParams = {
Expand Down Expand Up @@ -128,6 +130,10 @@ export class ActionInputs {
return this.params.overridePullString
}

get inUseFilePath() {
return this.params.inUseFilePath
}

private static validateInputs(params: ActionInputParameters) {
if (!params.standalone && !params.sysdigSecureToken) {
core.setFailed("Sysdig Secure Token is required for standard execution, please set your token or remove the standalone input.");
Expand Down Expand Up @@ -196,6 +202,10 @@ export class ActionInputs {
flags += ` ${this.params.extraParameters}`;
}

if (this.params.inUseFilePath) {
flags += ` --in-use-packages-file=${this.params.inUseFilePath}`;
}

if (this.params.mode == ScanMode.iac) {
flags += ` --iac`;

Expand Down
1 change: 1 addition & 0 deletions src/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export interface Package {
path: string
layerDigest?: string
suggestedFix?: string
running?: boolean
vulns?: Vuln[]
}

Expand Down
4 changes: 4 additions & 0 deletions src/summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function addVulnsByLayerTableToSummary(data: Report) {
{ data: '🟠 Medium', header: true },
{ data: '🟡 Low', header: true },
{ data: '⚪ Negligible', header: true },
{ data: 'In use', header: true },
{ data: 'Exploit', header: true },
],
...orderedPackagesBySeverity.map(layerPackage => {
Expand All @@ -109,6 +110,7 @@ function addVulnsByLayerTableToSummary(data: Report) {
{ data: mediumVulns.toString() },
{ data: lowVulns.toString() },
{ data: negligibleVulns.toString() },
{ data: layerPackage.running ? '✅' : '❌' },
{ data: exploits.toString() },
]
})
Expand Down Expand Up @@ -154,6 +156,7 @@ function getRulePkgMessage(rule: Rule, packages: Package[]) {
{ data: 'CVSS Version', header: true },
{ data: 'CVSS Vector', header: true },
{ data: 'Fixed Version', header: true },
{ data: 'InUse', header: true },
{ data: 'Exploitable', header: true }]];

rule.failures?.forEach(failure => {
Expand All @@ -171,6 +174,7 @@ function getRulePkgMessage(rule: Rule, packages: Package[]) {
{ data: `${vuln.cvssScore.value.version}` },
{ data: `${vuln.cvssScore.value.vector}` },
{ data: `${pkg.suggestedFix || "No fix available"}` },
{ data: `${pkg.running}` },
{ data: `${vuln.exploitable}` },
]);
}
Expand Down
Loading