Skip to content

Commit 45b3f34

Browse files
feat(vm): Support direct filesystem (#7058)
Signed-off-by: yusuke.koyoshi <yusuke.koyoshi@bizreach.co.jp>
1 parent ff403a3 commit 45b3f34

3 files changed

Lines changed: 15 additions & 7 deletions

File tree

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ require (
7676
github.com/liamg/jfather v0.0.7
7777
github.com/liamg/memoryfs v1.6.0
7878
github.com/magefile/mage v1.15.0
79-
github.com/masahiro331/go-disk v0.0.0-20220919035250-c8da316f91ac
79+
github.com/masahiro331/go-disk v0.0.0-20240625071113-56c933208fee
8080
github.com/masahiro331/go-ebs-file v0.0.0-20240112135404-d5fbb1d46323
8181
github.com/masahiro331/go-ext4-filesystem v0.0.0-20231208112839-4339555a0cd4
8282
github.com/masahiro331/go-mvn-version v0.0.0-20210429150710-d3157d602a08
8383
github.com/masahiro331/go-vmdk-parser v0.0.0-20221225061455-612096e4bbbd
84-
github.com/masahiro331/go-xfs-filesystem v0.0.0-20230608043311-a335f4599b70
84+
github.com/masahiro331/go-xfs-filesystem v0.0.0-20231205045356-1b22259a6c44
8585
github.com/mattn/go-shellwords v1.0.12
8686
github.com/microsoft/go-rustaudit v0.0.0-20220808201409-204dfee52032
8787
github.com/mitchellh/go-homedir v1.1.0

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,8 +1022,8 @@ github.com/markbates/oncer v1.0.0 h1:E83IaVAHygyndzPimgUYJjbshhDTALZyXxvk9FOlQRY
10221022
github.com/markbates/oncer v1.0.0/go.mod h1:Z59JA581E9GP6w96jai+TGqafHPW+cPfRxz2aSZ0mcI=
10231023
github.com/markbates/safe v1.0.1 h1:yjZkbvRM6IzKj9tlu/zMJLS0n/V351OZWRnF3QfaUxI=
10241024
github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0=
1025-
github.com/masahiro331/go-disk v0.0.0-20220919035250-c8da316f91ac h1:QyRucnGOLHJag1eB9CtuZwZk+/LpvTSYr5mnFLLFlgA=
1026-
github.com/masahiro331/go-disk v0.0.0-20220919035250-c8da316f91ac/go.mod h1:J7Vb0sf0JzOhT0uHTeCqO6dqP/ELVcQvQ6yQ/56ZRGw=
1025+
github.com/masahiro331/go-disk v0.0.0-20240625071113-56c933208fee h1:cgm8mE25x5XXX2oyvJDlyJ72K+rDu/4ZCYce2worNb8=
1026+
github.com/masahiro331/go-disk v0.0.0-20240625071113-56c933208fee/go.mod h1:rojbW5tVhH1cuVYFKZS+QX+VGXK45JVsRO+jW92kkKM=
10271027
github.com/masahiro331/go-ebs-file v0.0.0-20240112135404-d5fbb1d46323 h1:uQubA711SeYStvStohMLrdvRTTohdPHrEPFzerLcY9I=
10281028
github.com/masahiro331/go-ebs-file v0.0.0-20240112135404-d5fbb1d46323/go.mod h1:OdtzwqTtu49Gh5RFkNEU1SbcihIuVTtUipwHflqxckE=
10291029
github.com/masahiro331/go-ext4-filesystem v0.0.0-20231208112839-4339555a0cd4 h1:uHO44vOunB0oEtk+r8ifBbFOD0mr6+fmoyFNCgLE66k=
@@ -1032,8 +1032,8 @@ github.com/masahiro331/go-mvn-version v0.0.0-20210429150710-d3157d602a08 h1:AevU
10321032
github.com/masahiro331/go-mvn-version v0.0.0-20210429150710-d3157d602a08/go.mod h1:JOkBRrE1HvgTyjk6diFtNGgr8XJMtIfiBzkL5krqzVk=
10331033
github.com/masahiro331/go-vmdk-parser v0.0.0-20221225061455-612096e4bbbd h1:Y30EzvuoVp97b0unb/GOFXzBUKRXZXUN2e0wYmvC+ic=
10341034
github.com/masahiro331/go-vmdk-parser v0.0.0-20221225061455-612096e4bbbd/go.mod h1:5f7mCJGW9cJb8SDn3z8qodGxpMCOo8d/2nls/tiwRrw=
1035-
github.com/masahiro331/go-xfs-filesystem v0.0.0-20230608043311-a335f4599b70 h1:X6W6raTo07X0q4pvSI/68Pj/Ic4iIU2CfQU65OH0Zhc=
1036-
github.com/masahiro331/go-xfs-filesystem v0.0.0-20230608043311-a335f4599b70/go.mod h1:QKBZqdn6teT0LK3QhAf3K6xakItd1LonOShOEC44idQ=
1035+
github.com/masahiro331/go-xfs-filesystem v0.0.0-20231205045356-1b22259a6c44 h1:VmSjn0UCyfXUNdePDr7uM/uZTnGSp+mKD5+cYkEoLx4=
1036+
github.com/masahiro331/go-xfs-filesystem v0.0.0-20231205045356-1b22259a6c44/go.mod h1:QKBZqdn6teT0LK3QhAf3K6xakItd1LonOShOEC44idQ=
10371037
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
10381038
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
10391039
github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=

pkg/fanal/walker/vm.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ import (
99
"strings"
1010

1111
"github.com/masahiro331/go-disk"
12+
diskFs "github.com/masahiro331/go-disk/fs"
1213
"github.com/masahiro331/go-disk/gpt"
1314
"github.com/masahiro331/go-disk/mbr"
1415
"github.com/masahiro331/go-disk/types"
16+
"github.com/masahiro331/go-ext4-filesystem/ext4"
17+
"github.com/masahiro331/go-xfs-filesystem/xfs"
1518
"golang.org/x/xerrors"
1619

1720
"github.com/aquasecurity/trivy/pkg/fanal/vm/filesystem"
@@ -29,6 +32,11 @@ var requiredDiskName = []string{
2932
"3", // Common image name
3033
}
3134

35+
var checkFsFuncs = []diskFs.CheckFsFunc{
36+
ext4.Check,
37+
xfs.Check,
38+
}
39+
3240
func AppendPermitDiskName(s ...string) {
3341
requiredDiskName = append(requiredDiskName, s...)
3442
}
@@ -53,7 +61,7 @@ func (w *VM) Walk(vreader *io.SectionReader, root string, opt Option, fn WalkFun
5361
// This function will be called on each file.
5462
w.analyzeFn = fn
5563

56-
driver, err := disk.NewDriver(vreader)
64+
driver, err := disk.NewDriver(vreader, checkFsFuncs...)
5765
if err != nil {
5866
return xerrors.Errorf("failed to new disk driver: %w", err)
5967
}

0 commit comments

Comments
 (0)