-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support custom sandbox and analysis script path for dynamic analysis (#…
…744) * plumbing to support custom dynamic analysis sandbox and command Signed-off-by: Max Fisher <[email protected]> * support custom sandbox and analysis command in local analysis Signed-off-by: Max Fisher <[email protected]> * address review comments Signed-off-by: Max Fisher <[email protected]> * fix static analysis args generation Signed-off-by: Max Fisher <[email protected]> * fix nil pointer dereference in download Signed-off-by: Max Fisher <[email protected]> * sandbox.Sandbox: add argument names to Run() and improve documentation comments Signed-off-by: Max Fisher <[email protected]> --------- Signed-off-by: Max Fisher <[email protected]>
- Loading branch information
1 parent
94a0dab
commit db3da7d
Showing
15 changed files
with
158 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package dynamicanalysis | ||
|
||
import ( | ||
"github.com/ossf/package-analysis/internal/pkgmanager" | ||
"github.com/ossf/package-analysis/pkg/api/analysisrun" | ||
"github.com/ossf/package-analysis/pkg/api/pkgecosystem" | ||
) | ||
|
||
// defaultCommand returns the path (in the default sandbox image) | ||
// of the default dynamic analysis command for the ecosystem | ||
var defaultCommand = map[pkgecosystem.Ecosystem]string{ | ||
pkgecosystem.CratesIO: "/usr/local/bin/analyze-rust.py", | ||
pkgecosystem.NPM: "/usr/local/bin/analyze-node.js", | ||
pkgecosystem.Packagist: "/usr/local/bin/analyze-php.php", | ||
pkgecosystem.PyPI: "/usr/local/bin/analyze-python.py", | ||
pkgecosystem.RubyGems: "/usr/local/bin/analyze-ruby.rb", | ||
} | ||
|
||
func DefaultCommand(ecosystem pkgecosystem.Ecosystem) string { | ||
cmd := defaultCommand[ecosystem] | ||
if cmd == "" { | ||
panic("unsupported ecosystem: " + ecosystem) | ||
} | ||
return cmd | ||
} | ||
|
||
// MakeAnalysisArgs returns the arguments to pass to the dynamic analysis command in the sandbox | ||
// for the given phase of dynamic analysis on a package. The actual analysis command | ||
// depends on the ecosystem, see pkgmanager.PkgManager.DynamicAnalysisCommand() | ||
func MakeAnalysisArgs(p *pkgmanager.Pkg, phase analysisrun.DynamicPhase) []string { | ||
args := make([]string, 0) | ||
|
||
if p.IsLocal() { | ||
args = append(args, "--local", p.LocalPath()) | ||
} else if p.Version() != "" { | ||
args = append(args, "--version", p.Version()) | ||
} | ||
|
||
if phase == "" { | ||
args = append(args, "all") | ||
} else { | ||
args = append(args, string(phase)) | ||
} | ||
|
||
args = append(args, p.Name()) | ||
|
||
return args | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.