Skip to content
This repository was archived by the owner on Jun 21, 2022. It is now read-only.
Open
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
1 change: 1 addition & 0 deletions analyzer/all/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package all
import (
_ "github.com/aquasecurity/fanal/analyzer/buildinfo"
_ "github.com/aquasecurity/fanal/analyzer/command/apk"
_ "github.com/aquasecurity/fanal/analyzer/language/dotnet/deps"
_ "github.com/aquasecurity/fanal/analyzer/language/dotnet/nuget"
_ "github.com/aquasecurity/fanal/analyzer/language/golang/binary"
_ "github.com/aquasecurity/fanal/analyzer/language/golang/mod"
Expand Down
3 changes: 2 additions & 1 deletion analyzer/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ const (
TypeYarn Type = "yarn"

// .NET
TypeNuget Type = "nuget"
TypeNuget Type = "nuget"
TypeDotNetDeps Type = "dotnet-deps"

// Python
TypePythonPkg Type = "python-pkg"
Expand Down
49 changes: 49 additions & 0 deletions analyzer/language/dotnet/deps/deps.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package deps

import (
"context"
"os"
"strings"

"golang.org/x/xerrors"

"github.com/aquasecurity/fanal/analyzer"
"github.com/aquasecurity/fanal/analyzer/language"
"github.com/aquasecurity/fanal/types"
"github.com/aquasecurity/go-dep-parser/pkg/dotnet/core_deps"
)

func init() {
analyzer.RegisterAnalyzer(&depsLibraryAnalyzer{})
}

const (
version = 1
depsExtension = ".deps.json"
)

type depsLibraryAnalyzer struct{}

func (a depsLibraryAnalyzer) Analyze(_ context.Context, input analyzer.AnalysisInput) (*analyzer.AnalysisResult, error) {
// Set the default parser
parser := core_deps.NewParser()

res, err := language.Analyze(types.DotNetCore, input.FilePath, input.Content, parser)
if err != nil {
return nil, xerrors.Errorf(".Net Core dependencies analysis error: %w", err)
}

return res, nil
}

func (a depsLibraryAnalyzer) Required(filePath string, _ os.FileInfo) bool {
return strings.HasSuffix(filePath, depsExtension)
}

func (a depsLibraryAnalyzer) Type() analyzer.Type {
return analyzer.TypeDotNetDeps
}

func (a depsLibraryAnalyzer) Version() int {
return version
}
9 changes: 3 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ require (
github.com/GoogleCloudPlatform/docker-credential-gcr v2.0.5+incompatible
github.com/alicebob/miniredis/v2 v2.21.0
github.com/aquasecurity/defsec v0.59.0
github.com/aquasecurity/go-dep-parser v0.0.0-20220601061814-530f33ca32a9
github.com/aquasecurity/go-version v0.0.0-20210121072130-637058cfe492
github.com/aquasecurity/testdocker v0.0.0-20210911155206-e1e85f5a1516
github.com/aws/aws-sdk-go v1.44.25
github.com/docker/docker v20.10.14+incompatible
github.com/docker/go-connections v0.4.0
Expand Down Expand Up @@ -47,12 +50,6 @@ require (
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
)

require (
github.com/aquasecurity/go-dep-parser v0.0.0-20220531123411-1dabb532605f
github.com/aquasecurity/go-version v0.0.0-20210121072130-637058cfe492
github.com/aquasecurity/testdocker v0.0.0-20210911155206-e1e85f5a1516
)

require (
cloud.google.com/go v0.99.0 // indirect
cloud.google.com/go/storage v1.10.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
github.com/aquasecurity/defsec v0.59.0 h1:BmX5j5Y7+IhJ4hKYGIJWMcmVUqaIiTjtEqL5doT995Q=
github.com/aquasecurity/defsec v0.59.0/go.mod h1:42FxKif2itz+MHFlJ3TJjdroL9Jzj3THoexlueBTU5w=
github.com/aquasecurity/go-dep-parser v0.0.0-20220531123411-1dabb532605f h1:tBLOZtvvSqpe2TIcmEGpyLwVDLIORE1hRrdUiLE5bwE=
github.com/aquasecurity/go-dep-parser v0.0.0-20220531123411-1dabb532605f/go.mod h1:7EOQWQmyavVPY3fScbbPdd3dB/b0Q4ZbJ/NZCvNKrLs=
github.com/aquasecurity/go-dep-parser v0.0.0-20220601061814-530f33ca32a9 h1:skYc5Vf5gnzqSzV0UDzYNvBeN3NlOkxp5ABVFCjBIPM=
github.com/aquasecurity/go-dep-parser v0.0.0-20220601061814-530f33ca32a9/go.mod h1:7EOQWQmyavVPY3fScbbPdd3dB/b0Q4ZbJ/NZCvNKrLs=
github.com/aquasecurity/go-version v0.0.0-20210121072130-637058cfe492 h1:rcEG5HI490FF0a7zuvxOxen52ddygCfNVjP0XOCMl+M=
github.com/aquasecurity/go-version v0.0.0-20210121072130-637058cfe492/go.mod h1:9Beu8XsUNNfzml7WBf3QmyPToP1wm1Gj/Vc5UJKqTzU=
github.com/aquasecurity/testdocker v0.0.0-20210911155206-e1e85f5a1516 h1:moQmzbpLo5dxHQCyEhqzizsDSNrNhn/7uRTCZzo4A1o=
Expand Down
1 change: 1 addition & 0 deletions types/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const (
Composer = "composer"
Npm = "npm"
NuGet = "nuget"
DotNetCore = "dotnet-core"
Pip = "pip"
Pipenv = "pipenv"
Poetry = "poetry"
Expand Down