Skip to content
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
2 changes: 2 additions & 0 deletions admin/src/main/scala/com/neu/model/Vulnerability.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ case class VulnerabilityQuery(
matchTypeImage: Option[String],
imageName: Option[String],
matchTypeNode: Option[String],
imageBaseOS: Option[String],
matchTypeImageBaseOS: Option[String],
nodeName: Option[String],
matchTypeContainer: Option[String],
containerName: Option[String],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.neu.model
import spray.json.*

object VulnerabilityJsonProtocol extends DefaultJsonProtocol {
given vulnerabilityQueryFormat: RootJsonFormat[VulnerabilityQuery] = jsonFormat19(
given vulnerabilityQueryFormat: RootJsonFormat[VulnerabilityQuery] = jsonFormat21(
VulnerabilityQuery.apply
)
given vulnerabilityProfileEntryFormat: RootJsonFormat[VulnerabilityProfileEntry] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ export interface VulnerabilityQuery {
containerName?: string;
viewType: VulnerabilityView;
showAccepted?: boolean;
matchTypeImageBaseOS?: MatchTypeOption;
imageBaseOS?: string;
}

export interface VulnerabilitiesQuerySessionData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,144 +218,102 @@ <h1 mat-dialog-title>{{ 'general.FILTER_MATCH_ALL' | translate }}</h1>
<span>{{ 'admissionControl.names.CONTAINER' | translate }}</span>
</button>
</mat-menu>
<ng-container [ngSwitch]="view">
<div class="row col align-items-center">
<ng-container *ngSwitchCase="FilterView.SERVICE">
<label class="sr-only" for="serviceName">{{
'admissionControl.names.SERVICE' | translate
}}</label>
<label class="sr-only" for="serviceMatch">Match</label>
<mat-form-field class="col-2 pe-0 match">
<select
matNativeControl
formControlName="matchTypeService"
id="serviceMatch">
<option
*ngFor="let matchType of matchTypes"
[value]="matchType.id">
{{ matchType.name }}
</option>
</select>
</mat-form-field>
<mat-form-field class="col">
<input formControlName="serviceName" id="serviceName" matInput />
</mat-form-field>
</ng-container>
<ng-container *ngSwitchCase="FilterView.IMAGE">
<label class="sr-only" for="imageName">{{
'admissionControl.names.IMAGE' | translate
}}</label>
<label class="sr-only" for="imageMatch">Match</label>
<mat-form-field class="col-2 pe-0 match">
<select
matNativeControl
formControlName="matchTypeImage"
id="imageMatch">
<option
*ngFor="let matchType of matchTypes"
[value]="matchType.id">
{{ matchType.name }}
</option>
</select>
</mat-form-field>
<mat-form-field class="col">
<input formControlName="imageName" id="imageName" matInput />
</mat-form-field>
</ng-container>
<ng-container *ngSwitchCase="FilterView.NODE">
<label class="sr-only" for="nodeName">{{
'admissionControl.names.NODE' | translate
}}</label>
<label class="sr-only" for="nodeMatch">Match</label>
<mat-form-field class="col-2 pe-0 match">
<select
matNativeControl
formControlName="matchTypeNode"
id="nodeMatch">
<option
*ngFor="let matchType of matchTypes"
[value]="matchType.id">
{{ matchType.name }}
</option>
</select>
</mat-form-field>
<mat-form-field class="col">
<input formControlName="nodeName" id="nodeName" matInput />
</mat-form-field>
</ng-container>
<ng-container *ngSwitchCase="FilterView.CONTAINER">
<label class="sr-only" for="containerName">{{
'admissionControl.names.CONTAINER' | translate
}}</label>
<label class="sr-only" for="containerMatch">Match</label>
<mat-form-field class="col-2 pe-0 match">
<select
matNativeControl
formControlName="matchTypeContainer"
id="containerMatch">
<option
*ngFor="let matchType of matchTypes"
[value]="matchType.id">
{{ matchType.name }}
</option>
</select>
</mat-form-field>
<mat-form-field class="col">
<input
formControlName="containerName"
id="containerName"
matInput />
</mat-form-field>
</ng-container>
</div>
</ng-container>

<mat-form-field class="col-2 match">
<ng-container [ngSwitch]="view">
<select *ngSwitchCase="FilterView.SERVICE" matNativeControl formControlName="matchTypeService" id="serviceMatch">
<option *ngFor="let matchType of matchTypes" [value]="matchType.id">{{ matchType.name }}</option>
</select>
<select *ngSwitchCase="FilterView.IMAGE" matNativeControl formControlName="matchTypeImage" id="imageMatch">
<option *ngFor="let matchType of matchTypes" [value]="matchType.id">{{ matchType.name }}</option>
</select>
<select *ngSwitchCase="FilterView.NODE" matNativeControl formControlName="matchTypeNode" id="nodeMatch">
<option *ngFor="let matchType of matchTypes" [value]="matchType.id">{{ matchType.name }}</option>
</select>
<select *ngSwitchCase="FilterView.CONTAINER" matNativeControl formControlName="matchTypeContainer" id="containerMatch">
<option *ngFor="let matchType of matchTypes" [value]="matchType.id">{{ matchType.name }}</option>
</select>
</ng-container>
</mat-form-field>

<mat-form-field class="col">
<ng-container [ngSwitch]="view">
<input *ngSwitchCase="FilterView.SERVICE" formControlName="serviceName" id="serviceName" matInput />
<input *ngSwitchCase="FilterView.IMAGE" formControlName="imageName" id="imageName" matInput />
<input *ngSwitchCase="FilterView.NODE" formControlName="nodeName" id="nodeName" matInput />
<input *ngSwitchCase="FilterView.CONTAINER" formControlName="containerName" id="containerName" matInput />
</ng-container>
</mat-form-field>
</section>

<section class="row mx-0 align-items-center" *ngIf="view === FilterView.IMAGE">
<label class="col-2 font-weight-normal">
{{ 'vulnerability.advanced_filter.image_base_os.label' | translate }}
</label>
<mat-form-field class="col-2 match">
<select matNativeControl formControlName="matchTypeImageBaseOS" id="imageBaseOSMatch">
<option *ngFor="let matchType of matchTypes" [value]="matchType.id">
{{ matchType.name }}
</option>
</select>
</mat-form-field>
<mat-form-field class="col">
<input formControlName="imageBaseOS" id="imageBaseOS" matInput [placeholder]="'vulnerability.advanced_filter.image_base_os.placeholder' | translate" />
</mat-form-field>
</section>
</form>
</div>
<div>

<div class="mt-3">
<ng-container *ngIf="form.controls.serviceName.value">
<span
class="badge badge-secondary mb-1 me-1 ms-0 d-inline-flex justify-content-center align-items-center"
>Service
<span class="badge badge-secondary mb-1 me-1 ms-0 d-inline-flex justify-content-center align-items-center">
Service
{{ form.get('matchTypeService')?.value === 'equals' ? '=' : '~' }}
{{ form.controls.serviceName.value }}
<button (click)="clear(FilterView.SERVICE)" class="remove-button">
<i class="eos-icons">close</i>
</button></span
>
</button>
</span>
</ng-container>
<ng-container *ngIf="form.controls.imageName.value">
<span
class="badge badge-secondary mb-1 me-1 ms-0 d-inline-flex justify-content-center align-items-center"
>Image
<span class="badge badge-secondary mb-1 me-1 ms-0 d-inline-flex justify-content-center align-items-center">
Image
{{ form.get('matchTypeImage')?.value === 'equals' ? '=' : '~' }}
{{ form.controls.imageName.value }}
<button (click)="clear(FilterView.IMAGE)" class="remove-button">
<i class="eos-icons">close</i>
</button></span
>
</button>
</span>
</ng-container>
<ng-container *ngIf="form.controls.nodeName.value">
<span
class="badge badge-secondary mb-1 me-1 ms-0 d-inline-flex justify-content-center align-items-center"
>Node
<span class="badge badge-secondary mb-1 me-1 ms-0 d-inline-flex justify-content-center align-items-center">
Node
{{ form.get('matchTypeNode')?.value === 'equals' ? '=' : '~' }}
{{ form.controls.nodeName.value }}
<button (click)="clear(FilterView.NODE)" class="remove-button">
<i class="eos-icons">close</i>
</button></span
>
</button>
</span>
</ng-container>
<ng-container *ngIf="form.controls.containerName.value">
<span
class="badge badge-secondary mb-1 me-1 ms-0 d-inline-flex justify-content-center align-items-center"
>Container
<span class="badge badge-secondary mb-1 me-1 ms-0 d-inline-flex justify-content-center align-items-center">
Container
{{ form.get('matchTypeContainer')?.value === 'equals' ? '=' : '~' }}
{{ form.controls.containerName.value }}
<button (click)="clear(FilterView.CONTAINER)" class="remove-button">
<i class="eos-icons">close</i>
</button></span
>
</button>
</span>
</ng-container>
<ng-container *ngIf="form.controls.imageBaseOS?.value">
<span class="badge badge-secondary mb-1 me-1 ms-0 d-inline-flex justify-content-center align-items-center">
{{ 'vulnerability.advanced_filter.image_base_os.label' | translate }}
{{ form.get('matchTypeImageBaseOS')?.value === 'equals' ? '=' : '~' }}
{{ form.controls.imageBaseOS.value }}
<button (click)="clear(FilterView.IMAGE_BASE_OS)" class="remove-button">
<i class="eos-icons">close</i>
</button>
</span>
</ng-container>
<ng-container
[ngTemplateOutletContext]="{
Expand Down Expand Up @@ -397,6 +355,6 @@ <h1 mat-dialog-title>{{ 'general.FILTER_MATCH_ALL' | translate }}</h1>
(click)="clear(type === 'V2' ? FilterView.V2 : FilterView.V3)"
class="remove-button">
<i class="eos-icons">close</i>
</button></span
>
</button>
</span>
</ng-template>
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ enum FilterView {
CONTAINER = 3,
V2 = 5,
V3 = 4,
IMAGE_BASE_OS = 6,
}

const today = new Date();
Expand Down Expand Up @@ -102,6 +103,11 @@ export class VulnerabilityItemsTableFilterComponent implements OnInit {
this.form.get('matchTypeImage')?.setValue(this.matchTypes[0].id);
break;
}
case FilterView.IMAGE_BASE_OS: {
this.form.controls.imageBaseOS.reset();
this.form.get('matchTypeImageBaseOS')?.setValue(this.matchTypes[0].id);
break;
}
case FilterView.NODE: {
this.form.controls.nodeName.reset();
this.form.get('matchTypeNode')?.setValue(this.matchTypes[0].id);
Expand Down Expand Up @@ -180,6 +186,8 @@ export class VulnerabilityItemsTableFilterComponent implements OnInit {
serviceName: new FormControl(filter.serviceName),
matchTypeImage: new FormControl(filter.matchTypeImage),
imageName: new FormControl(filter.imageName),
matchTypeImageBaseOS: new FormControl(filter.matchTypeImageBaseOS || this.matchTypes[0].id),
imageBaseOS: new FormControl(filter.imageBaseOS || ''),
matchTypeNode: new FormControl(filter.matchTypeNode),
nodeName: new FormControl(filter.nodeName),
matchTypeContainer: new FormControl(filter.matchTypeContainer),
Expand Down
8 changes: 8 additions & 0 deletions admin/webapp/websrc/assets/i18n/en-common.json
Original file line number Diff line number Diff line change
Expand Up @@ -3537,6 +3537,14 @@
"REMOVE_VERIFIER_NG": "Error happens when removing verifier!"
}
},
"vulnerability": {
"advanced_filter": {
"image_base_os": {
"label": "Image Base OS",
"placeholder": "e.g alpine, ubuntu, redhat"
}
}
},
"just_now": "just now",
"seconds_ago": "{{time}} seconds ago",
"a_minute_ago": "a minute ago",
Expand Down
8 changes: 8 additions & 0 deletions admin/webapp/websrc/assets/i18n/zh_cn-common.json
Original file line number Diff line number Diff line change
Expand Up @@ -3531,6 +3531,14 @@
"REMOVE_VERIFIER_NG": "检测器删除时发生错误!"
}
},
"vulnerability": {
"advanced_filter": {
"image_base_os": {
"label": "镜像基础操作系统",
"placeholder": "例如 alpine, ubuntu, redhat"
}
}
},
"just_now": "刚才",
"seconds_ago": "{{time}}秒前",
"a_minute_ago": "1分钟前",
Expand Down