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

refactor(api): scanners statuses of AssetScan #825

Merged
merged 28 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
979bc90
refactor(asset-scan-scanners): initial refactor
adamtagscherer Oct 18, 2023
ac3b700
fix(asset-scan-scanners): add missing file
adamtagscherer Oct 18, 2023
fb8c49f
test(asset-scan-scanners): fix unit tests
adamtagscherer Oct 18, 2023
bc606d2
refactor(asset-scan-scanners): move the status object one level upper
adamtagscherer Oct 25, 2023
b29e7cc
fix(asset-scan-scanners): run linter
adamtagscherer Oct 25, 2023
cb835f4
fix(asset-scan-scanners): db schema
adamtagscherer Oct 25, 2023
15fdeff
fix(asset-scan-scanners): run linter
adamtagscherer Oct 25, 2023
c8b903c
fix(asset-scan-scanners): run linter
adamtagscherer Oct 25, 2023
524932c
fix(asset-scan-scanners): run linter
adamtagscherer Oct 25, 2023
f3eef86
fix(asset-scan-scanners): run linter
adamtagscherer Oct 25, 2023
62c6045
refactor(asset-scan-scanners): rename reasons
adamtagscherer Oct 25, 2023
7d761e0
refactor(asset-scan-scanners): exploits scanner
adamtagscherer Oct 26, 2023
83cb4eb
refactor(asset-scan-scanners): vulnerabilities scanner
adamtagscherer Oct 26, 2023
d09edc7
refactor(asset-scan-scanners): malware scanner
adamtagscherer Oct 27, 2023
5e3c3bb
refactor(asset-scan-scanners): rootkit scanner
adamtagscherer Oct 27, 2023
f246ffd
refactor(asset-scan-scanners): secret scanner
adamtagscherer Oct 27, 2023
83c8ce8
refactor(asset-scan-scanners): misconfiguration scanner
adamtagscherer Oct 27, 2023
230d555
refactor(asset-scan-scanners): infofinder scanner
adamtagscherer Oct 27, 2023
6325135
fix(asset-scan-scanners): linter
adamtagscherer Oct 27, 2023
7453c0e
test(asset-scan-scanners): helpers_test.go
adamtagscherer Oct 27, 2023
3a08c9b
test(asset-scan-scanners): helpers_test.go
adamtagscherer Oct 27, 2023
c237470
fix(asset-scan-scanners): frontend
adamtagscherer Oct 30, 2023
5d30c05
fix(asset-scan-scanners): demo scanner statuses
adamtagscherer Oct 31, 2023
98fbead
refactor(scanner-statuses): guard nils, remove unnecessary items from…
adamtagscherer Nov 21, 2023
773ddd6
refactor(scanner-statuses): add ScannerStatusState prefix to statuses
adamtagscherer Nov 21, 2023
7266c51
fix(scanner-statuses): make lint-go
adamtagscherer Nov 22, 2023
9ae2e26
refactor(scanner-statuses): reference propert assetScan property
adamtagscherer Nov 22, 2023
54716a8
refactor(scanner-statuses): reorganize presenter code
adamtagscherer Nov 22, 2023
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
101 changes: 86 additions & 15 deletions api/models/models.gen.go

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

12 changes: 12 additions & 0 deletions api/models/scanner_status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package models

import "time"

func NewScannerStatus(s ScannerStatusState, r ScannerStatusReason, m *string) *ScannerStatus {
return &ScannerStatus{
State: s,
Reason: r,
Message: m,
LastTransitionTime: time.Now(),
}
}
93 changes: 75 additions & 18 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2378,7 +2378,7 @@ components:
$ref: '#/components/schemas/ScanRelationship'
status:
$ref: '#/components/schemas/AssetScanStatus'
sboms:
sbom:
paralta marked this conversation as resolved.
Show resolved Hide resolved
$ref: '#/components/schemas/SbomScan'
vulnerabilities:
$ref: '#/components/schemas/VulnerabilityScan'
Expand Down Expand Up @@ -2418,6 +2418,63 @@ components:
# - asset
# - scan

ScannerStatus:
type: object
required:
- state
- reason
- lastTransitionTime
properties:
state:
description: |
Describes the state of a scanner on the asset.

| State | Description |
| ----------- | ------------------------------------------------------------------------ |
| Pending | Scanner is pending and waits for state transition to InProgress state |
| InProgress | Scanning is being performed |
| Skipped | Scanner is **not** scheduled |
| Failed | Scanner has failed, check *reason* and *message* fields for the details |
| Done | Scanner has finished scanning with no errors |
type: string
enum:
- Pending
- InProgress
- Skipped
- Failed
- Done
x-enum-varnames:
- ScannerStatusStatePending
- ScannerStatusStateInProgress
- ScannerStatusStateSkipped
- ScannerStatusStateFailed
- ScannerStatusStateDone
reason:
description: |
Machine readable reason for state transition.

| State | Reason | Description |
| ---------- | ----------------- | ------------------------------------------- |
| Pending | Scheduled | Scanner has been enabled in ScanConfig |
| InProgress | Scanning | Scanner is currently running |
| Skipped | NotScheduled | Scanner hasn't been enabled in ScanConfig |
| Failed | Error | Scanner finished with an error |
| Done | Success | Scanner finished successfully |
type: string
enum:
- Scheduled
- Scanning
- NotScheduled
- Error
- Success
message:
description: Human readable message.
type: string
lastTransitionTime:
description: Last date time when the status has changed.
type: string
format: date-time

AssetScanStats:
type: object
properties:
Expand Down Expand Up @@ -2493,7 +2550,7 @@ components:
status:
$ref: '#/components/schemas/AssetScanStatus'
readOnly: true
sboms:
sbom:
$ref: '#/components/schemas/SbomScan'
readOnly: true
vulnerabilities:
Expand Down Expand Up @@ -2581,22 +2638,6 @@ components:
properties:
general:
$ref: '#/components/schemas/AssetScanState'
sbom:
$ref: '#/components/schemas/AssetScanState'
vulnerabilities:
$ref: '#/components/schemas/AssetScanState'
malware:
$ref: '#/components/schemas/AssetScanState'
rootkits:
$ref: '#/components/schemas/AssetScanState'
secrets:
$ref: '#/components/schemas/AssetScanState'
misconfigurations:
$ref: '#/components/schemas/AssetScanState'
exploits:
$ref: '#/components/schemas/AssetScanState'
infoFinder:
$ref: '#/components/schemas/AssetScanState'

AssetScanState:
type: object
Expand Down Expand Up @@ -2993,6 +3034,8 @@ components:
SbomScan:
type: object
properties:
status:
$ref: "#/components/schemas/ScannerStatus"
packages:
type: array
items:
Expand All @@ -3002,6 +3045,8 @@ components:
VulnerabilityScan:
type: object
properties:
status:
$ref: "#/components/schemas/ScannerStatus"
vulnerabilities:
type: array
items:
Expand All @@ -3011,6 +3056,8 @@ components:
MalwareScan:
type: object
properties:
status:
$ref: "#/components/schemas/ScannerStatus"
malware:
type: array
items:
Expand All @@ -3025,6 +3072,8 @@ components:
RootkitScan:
type: object
properties:
status:
$ref: '#/components/schemas/ScannerStatus'
rootkits:
type: array
items:
Expand All @@ -3034,6 +3083,8 @@ components:
SecretScan:
type: object
properties:
status:
$ref: "#/components/schemas/ScannerStatus"
secrets:
type: array
items:
Expand All @@ -3043,6 +3094,8 @@ components:
MisconfigurationScan:
type: object
properties:
status:
$ref: "#/components/schemas/ScannerStatus"
scanners:
type: array
items:
Expand All @@ -3057,6 +3110,8 @@ components:
InfoFinderScan:
type: object
properties:
status:
$ref: "#/components/schemas/ScannerStatus"
scanners:
type: array
items:
Expand Down Expand Up @@ -3095,6 +3150,8 @@ components:
ExploitScan:
type: object
properties:
status:
$ref: "#/components/schemas/ScannerStatus"
exploits:
type: array
items:
Expand Down
Loading