Skip to content

Commit 9f767ca

Browse files
committed
added support for CoreOS
1 parent d3cd101 commit 9f767ca

File tree

11 files changed

+68
-1
lines changed

11 files changed

+68
-1
lines changed

docs/docs/coverage/os/coreos.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# CoreOS
2+
Trivy supports the following scanners for OS packages.
3+
4+
| Scanner | Supported |
5+
| :-----------: | :-------: |
6+
| SBOM ||
7+
| Vulnerability | - |
8+
| License | - |
9+
10+
Please see [here](index.md#supported-os) for supported versions.
11+
12+
## SBOM
13+
Trivy detects packages that are listed in the [software inventory].
14+
15+
[software inventory]: https://bottlerocket.dev/en/os/1.37.x/concepts/variants/#software-inventory

docs/docs/coverage/os/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ Trivy supports operating systems for
2828
| [SUSE Linux Enterprise](suse.md) | 11, 12, 15 | zypper/rpm |
2929
| [SUSE Linux Enterprise Micro](suse.md)| 5, 6 | zypper/rpm |
3030
| [Photon OS](photon.md) | 1.0, 2.0, 3.0, 4.0 | tndf/yum/rpm |
31+
| [CoreOS Container Linux](coreos.md) | All versions (EOL) | rpm |
3132
| [Echo](echo.md) | (n/a) | apt/dpkg |
3233
| [Debian GNU/Linux](debian.md) | 7, 8, 9, 10, 11, 12 | apt/dpkg |
3334
| [Ubuntu](ubuntu.md) | All versions supported by Canonical | apt/dpkg |
3435
| [Bottlerocket](bottlerocket.md) | 1.7.0 and upper | bottlerocket |
35-
| [OSs with installed Conda](../others/conda.md) | - | conda |
36+
| [OSs with installed Conda](../others/conda.md) | - | conda |
3637

3738
## Supported container images
3839

@@ -45,6 +46,7 @@ Each page gives more details.
4546

4647
[^1]: CentOS Stream is not supported
4748
[^2]: https://github.com/GoogleContainerTools/distroless
49+
[^3]: CoreOS Container Linux reached end-of-life on May 26, 2020. Consider migrating to Fedora CoreOS.
4850

4951

5052
[sbom]: ../../supply-chain/sbom.md

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ nav:
9090
- Ubuntu: docs/coverage/os/ubuntu.md
9191
- Wolfi: docs/coverage/os/wolfi.md
9292
- Google Distroless (Images): docs/coverage/os/google-distroless.md
93+
- CoreOS Container Linux: docs/coverage/os/coreos.md
9394
- Language:
9495
- Overview: docs/coverage/language/index.md
9596
- C/C++: docs/coverage/language/c.md
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package coreos
2+
3+
import (
4+
"context"
5+
6+
osver "github.com/aquasecurity/trivy/pkg/detector/ospkg/version"
7+
ftypes "github.com/aquasecurity/trivy/pkg/fanal/types"
8+
"github.com/aquasecurity/trivy/pkg/log"
9+
"github.com/aquasecurity/trivy/pkg/types"
10+
)
11+
12+
// Scanner implements the CoreOS scanner
13+
type Scanner struct {
14+
}
15+
16+
// NewScanner is the factory method for Scanner
17+
func NewScanner() *Scanner {
18+
return &Scanner{}
19+
}
20+
21+
func (s *Scanner) Detect(ctx context.Context, _ string, _ *ftypes.Repository, _ []ftypes.Package) ([]types.DetectedVulnerability, error) {
22+
log.InfoContext(ctx, "Vulnerability detection of CoreOS packages is currently not supported.")
23+
return nil, nil
24+
}
25+
26+
func (s *Scanner) IsSupportedVersion(ctx context.Context, osFamily ftypes.OSType, osVer string) bool {
27+
return osver.Supported(ctx, nil, osFamily, osver.Minor(osVer))
28+
}

pkg/detector/ospkg/detect.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/aquasecurity/trivy/pkg/detector/ospkg/azure"
1313
"github.com/aquasecurity/trivy/pkg/detector/ospkg/bottlerocket"
1414
"github.com/aquasecurity/trivy/pkg/detector/ospkg/chainguard"
15+
"github.com/aquasecurity/trivy/pkg/detector/ospkg/coreos"
1516
"github.com/aquasecurity/trivy/pkg/detector/ospkg/debian"
1617
"github.com/aquasecurity/trivy/pkg/detector/ospkg/driver"
1718
"github.com/aquasecurity/trivy/pkg/detector/ospkg/echo"
@@ -55,6 +56,7 @@ var (
5556
ftypes.Chainguard: chainguard.NewScanner(),
5657
ftypes.Echo: echo.NewScanner(),
5758
ftypes.MinimOS: minimos.NewScanner(),
59+
ftypes.CoreOS: coreos.NewScanner(),
5860
}
5961

6062
// providers dynamically generate drivers based on package information

pkg/fanal/analyzer/const.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const (
2626
TypeSUSE Type = "suse"
2727
TypeUbuntu Type = "ubuntu"
2828
TypeUbuntuESM Type = "ubuntu-esm"
29+
TypeCoreOS Type = "coreos"
2930

3031
// OS Package
3132
TypeApk Type = "apk"

pkg/fanal/analyzer/os/release/release.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ func (a osReleaseAnalyzer) Analyze(_ context.Context, input analyzer.AnalysisInp
7878
family = types.Echo
7979
case "minimos":
8080
family = types.MinimOS
81+
case "coreos":
82+
family = types.CoreOS
8183
}
8284

8385
if family != "" && versionID != "" {

pkg/fanal/analyzer/os/release/release_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,16 @@ func Test_osReleaseAnalyzer_Analyze(t *testing.T) {
179179
},
180180
},
181181
},
182+
{
183+
name: "CoreOS",
184+
inputFile: "testdata/coreos",
185+
want: &analyzer.AnalysisResult{
186+
OS: types.OS{
187+
Family: types.CoreOS,
188+
Name: "3.15.4",
189+
},
190+
},
191+
},
182192
{
183193
name: "Unknown OS",
184194
inputFile: "testdata/unknown",
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ID=coreos
2+
VERSION_ID=3.15.4

pkg/fanal/analyzer/pkg/rpm/rpm.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ var (
4040
// SQLite3
4141
"usr/lib/sysimage/rpm/rpmdb.sqlite",
4242
"var/lib/rpm/rpmdb.sqlite",
43+
44+
// CoreOS
45+
"usr/share/rpm/rpmdb.sqlite",
4346
}
4447

4548
errUnexpectedNameFormat = xerrors.New("unexpected name format")

0 commit comments

Comments
 (0)