-
Notifications
You must be signed in to change notification settings - Fork 12
add checksum_cmd directive to command #252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,8 +6,10 @@ import ( | |
| "encoding/hex" | ||
| "fmt" | ||
| "os" | ||
| "os/exec" | ||
| "path/filepath" | ||
| "sort" | ||
| "strings" | ||
|
|
||
| "github.com/lets-cli/lets/internal/set" | ||
| "github.com/lets-cli/lets/internal/util" | ||
|
|
@@ -103,6 +105,19 @@ func getChecksumsKeys(mapping map[string][]string) []string { | |
| return keys | ||
| } | ||
|
|
||
| func CalculateChecksumFromCmd(shell string, workDir string, script string) (string, error) { | ||
| cmd := exec.Command(shell, "-c", script) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. security (go.lang.security.audit.dangerous-exec-command): Detected non-static command inside Command. Audit the input to 'exec.Command'. If unverified user data can reach this call site, this is a code injection vulnerability. A malicious actor can inject a malicious script to execute arbitrary code. Source: opengrep |
||
| cmd.Dir = workDir | ||
|
|
||
| out, err := cmd.Output() | ||
| if err != nil { | ||
| return "", fmt.Errorf("can not calculate checksum from cmd: %s: %w", script, err) | ||
| } | ||
|
|
||
| res := string(out) | ||
| return strings.TrimSpace(res), nil | ||
| } | ||
|
|
||
| // CalculateChecksumFromSources calculates checksum from checksumSources. | ||
| func CalculateChecksumFromSources(workDir string, checksumSources map[string][]string) (map[string]string, error) { | ||
| checksumMap := make(map[string]string) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.