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

Adding support for critical severity in the tree and triage #660

Merged
merged 15 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 14 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
15 changes: 15 additions & 0 deletions media/details.css
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@
width: 100%;
}

.select-critical {
margin: 0.4em;
border-color: transparent;
border-radius: 4px;
padding: 0.2em 0.5em 0.2em 1.5em;
background-color: var(--vscode-input-background);
background-image: url("./icons/critical_untoggle.svg");
background-repeat: no-repeat;
background-size: 0.8em auto;
background-position: 0.4em center;
color: var(--vscode-foreground);
cursor: pointer;
}

.select-high {
margin: 0.4em;
border-color: transparent;
Expand All @@ -92,6 +106,7 @@
color: var(--vscode-foreground);
cursor: pointer;
}

.select-medium {
margin: 0.4em;
border-color: transparent;
Expand Down
1 change: 1 addition & 0 deletions media/icons/critical_toggle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions media/icons/critical_untoggle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 41 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,20 @@
"title": "Clear SCA results tree",
"icon": "$(refresh)"
},
{
"command": "ast-results.filterCritical_untoggle",
"category": "ast-results",
"title": "CRITICAL",
"icon": "media/icons/critical_untoggle.svg",
"enablement": "ast-results.isValidCredentials && view == astResults"
},
{
"command": "ast-results.filterCritical_toggle",
"category": "ast-results",
"title": "CRITICAL",
"icon": "media/icons/critical_toggle.svg",
"enablement": "ast-results.isValidCredentials && view == astResults"
},
{
"command": "ast-results.filterHigh_toggle",
"category": "ast-results",
Expand Down Expand Up @@ -256,6 +270,13 @@
"icon": "media/icons/info_untoggle.svg",
"enablement": "ast-results.isValidCredentials && view == astResults"
},
{
"command": "ast-results.filterCritical",
"category": "ast-results",
"title": "Filter severity: Critical",
"icon": "media/icons/high_untoggle.svg",
"enablement": "ast-results.isValidCredentials"
},
{
"command": "ast-results.filterHigh",
"category": "ast-results",
Expand Down Expand Up @@ -605,43 +626,53 @@
"when": "view == astResults && ast-results.cancelScanButton || view == astResults && !ast-results.createScanButton && ast-results.cancelScanButton"
},
{
"command": "ast-results.filterHigh_untoggle",
"command": "ast-results.filterCritical_untoggle",
"group": "navigation@1",
"when": "view == astResults && ast-results-critical"
},
{
"command": "ast-results.filterCritical_toggle",
"group": "navigation@1",
"when": "view == astResults && !ast-results-critical"
},
{
"command": "ast-results.filterHigh_untoggle",
"group": "navigation@2",
"when": "view == astResults && ast-results-high"
},
{
"command": "ast-results.filterHigh_toggle",
"group": "navigation@1",
"group": "navigation@2",
"when": "view == astResults && !ast-results-high"
},
{
"command": "ast-results.filterMedium_untoggle",
"group": "navigation@2",
"group": "navigation@3",
"when": "view == astResults && ast-results-medium"
},
{
"command": "ast-results.filterMedium_toggle",
"group": "navigation@2",
"group": "navigation@3",
"when": "view == astResults && !ast-results-medium"
},
{
"command": "ast-results.filterLow_untoggle",
"group": "navigation@3",
"group": "navigation@4",
"when": "view == astResults && ast-results-low"
},
{
"command": "ast-results.filterLow_toggle",
"group": "navigation@3",
"group": "navigation@4",
"when": "view == astResults && !ast-results-low"
},
{
"command": "ast-results.filterInfo_untoggle",
"group": "navigation@4",
"group": "navigation@5",
"when": "view == astResults && ast-results-info"
},
{
"command": "ast-results.filterInfo_toggle",
"group": "navigation@4",
"group": "navigation@5",
"when": "view == astResults && !ast-results-info"
},
{
Expand Down Expand Up @@ -736,7 +767,7 @@
},
{
"submenu": "ast-results.filterBy",
"group": "navigation@5",
"group": "navigation@6",
"when": "view == astResults"
}
]
Expand Down Expand Up @@ -919,4 +950,4 @@
"pre-commit": "lint-staged"
}
}
}
}
47 changes: 47 additions & 0 deletions src/commands/filterCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class FilterCommand {
context: vscode.ExtensionContext;
logs: Logs;
private activeSeverities: SeverityLevel[] = [
SeverityLevel.critical,
SeverityLevel.high,
SeverityLevel.medium,
];
Expand All @@ -38,6 +39,7 @@ export class FilterCommand {
}

public registerFilters() {
this.registerFilterCriticalCommand();
this.registerFilterHighCommand();
this.registerFilterMediumCommand();
this.registerFilterLowCommand();
Expand All @@ -53,6 +55,11 @@ export class FilterCommand {

public async initializeFilters() {
this.logs.info(messages.initilizeSeverities);

const critical = this.context.globalState.get<boolean>(constants.criticalFilter) ?? true;
this.updateSeverities(SeverityLevel.critical, critical);
await updateStateFilter(this.context, constants.criticalFilter, critical);

const high = this.context.globalState.get<boolean>(constants.highFilter) ?? true;
this.updateSeverities(SeverityLevel.high, high);
await updateStateFilter(this.context, constants.highFilter, high);
Expand Down Expand Up @@ -106,6 +113,46 @@ export class FilterCommand {
await vscode.commands.executeCommand(commands.refreshTree);
}


private registerFilterCriticalCommand() {
this.context.subscriptions.push(
vscode.commands.registerCommand(
commands.filterCriticalToggle,
async () =>
await this.filter(
this.logs,
this.context,
SeverityLevel.critical,
constants.criticalFilter
)
)
);
this.context.subscriptions.push(
vscode.commands.registerCommand(
commands.filterCriticalUntoggle,
async () =>
await this.filter(
this.logs,
this.context,
SeverityLevel.critical,
constants.criticalFilter
)
)
);
this.context.subscriptions.push(
vscode.commands.registerCommand(
commands.filterCritical,
async () =>
await this.filter(
this.logs,
this.context,
SeverityLevel.critical,
constants.criticalFilter
)
)
);
}

private registerFilterHighCommand() {
this.context.subscriptions.push(
vscode.commands.registerCommand(
Expand Down
Loading
Loading