Skip to content

Commit

Permalink
PR fixes
Browse files Browse the repository at this point in the history
Signed-off-by: balteraivshay <[email protected]>
  • Loading branch information
balteravishay committed Sep 19, 2024
1 parent 43eee27 commit acacce5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion checks/fileparser/csproj_parser.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 OpenSSF Scorecard Authors
// Copyright 2024 OpenSSF Scorecard Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
15 changes: 12 additions & 3 deletions checks/raw/pinned_dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func collectCsprojDependenciesData(c *checker.CheckRequest) ([]checker.Dependenc
if err := fileparser.OnMatchingFileContentDo(c.RepoClient, fileparser.PathMatcher{
Pattern: "*.csproj",
CaseSensitive: false,
}, analyseCsprojLockedMode, &csprojDeps); err != nil {
}, analyseCsprojLockedMode, &csprojDeps, c.Dlogger); err != nil {
return nil, 0, err
}

Expand All @@ -124,7 +124,16 @@ func analyseCsprojLockedMode(path string, content []byte, args ...interface{}) (

err, pinned := fileparser.IsRestoreLockedModeEnabled(content)
if err != nil {
return true, err
dl, ok := args[1].(checker.DetailLogger)
if !ok {
// panic if it is not correct type
panic(fmt.Sprintf("expected type checker.DetailLogger, got %v", reflect.TypeOf(args[1])))
}

dl.Warn(&checker.LogMessage{
Text: fmt.Sprintf("malformed csproj file: %e", err),
})
return true, nil
}

dependency := checker.Dependency{
Expand All @@ -133,7 +142,7 @@ func analyseCsprojLockedMode(path string, content []byte, args ...interface{}) (
Type: finding.FileTypeSource,
Offset: 1,
EndOffset: 1,
Snippet: "hello",
Snippet: "<RestoreLockedMode>true</RestoreLockedMode>",
},
Pinned: asBoolPointer(pinned),
Type: checker.DependencyUseTypeNugetCommand,
Expand Down

0 comments on commit acacce5

Please sign in to comment.