-
Notifications
You must be signed in to change notification settings - Fork 196
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
[allow-insecure] Allow insecure packages with --allow-insecure flag #1265
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0a7a0e2
[allow-insecure] Allow insecure packages with devbox.json field
mikeland73 801257c
Merge remote-tracking branch 'origin/main' into landau/insecure
mikeland73 0272487
Merge branch 'main' into landau/insecure
mikeland73 a6b65f5
Re-write using lock file and better nix commands
mikeland73 be2a028
Clean up and fix tests
mikeland73 23ba95a
Fix lint issue
mikeland73 3fb1ac2
Fix tests
mikeland73 0599c2f
Improve logic
mikeland73 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,4 @@ | |
"nixpkgs": { | ||
"commit": "3364b5b117f65fe1ce65a3cdd5612a078a3b31e3" | ||
} | ||
} | ||
} |
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,15 @@ | ||
{ | ||
"packages": [ | ||
"nodejs@16" | ||
], | ||
"shell": { | ||
"init_hook": [ | ||
"echo 'Welcome to devbox!' > /dev/null" | ||
], | ||
"scripts": { | ||
"run_test": [ | ||
"node --version" | ||
] | ||
} | ||
} | ||
} |
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,12 @@ | ||
{ | ||
"lockfile_version": "1", | ||
"packages": { | ||
"nodejs@16": { | ||
"allow_insecure": true, | ||
"last_modified": "2023-06-29T16:20:38Z", | ||
"resolved": "github:NixOS/nixpkgs/3c614fbc76fc152f3e1bc4b2263da6d90adf80fb#nodejs_16", | ||
"source": "devbox-search", | ||
"version": "16.20.1" | ||
} | ||
} | ||
} |
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
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,56 @@ | ||
package nix | ||
|
||
import ( | ||
"encoding/json" | ||
"os" | ||
"strconv" | ||
) | ||
|
||
func EvalPackageName(path string) (string, error) { | ||
cmd := command("eval", "--raw", path+".name") | ||
out, err := cmd.Output() | ||
if err != nil { | ||
return "", err | ||
} | ||
return string(out), nil | ||
} | ||
|
||
// PackageIsInsecure is a fun little nix eval that maybe works. | ||
func PackageIsInsecure(path string) bool { | ||
cmd := command("eval", path+".meta.insecure") | ||
out, err := cmd.Output() | ||
if err != nil { | ||
// We can't know for sure, but probably not. | ||
return false | ||
} | ||
var insecure bool | ||
if err := json.Unmarshal(out, &insecure); err != nil { | ||
// We can't know for sure, but probably not. | ||
return false | ||
} | ||
return insecure | ||
} | ||
|
||
func PackageKnownVulnerabilities(path string) []string { | ||
cmd := command("eval", path+".meta.knownVulnerabilities") | ||
out, err := cmd.Output() | ||
if err != nil { | ||
// We can't know for sure, but probably not. | ||
return nil | ||
} | ||
var vulnerabilities []string | ||
if err := json.Unmarshal(out, &vulnerabilities); err != nil { | ||
// We can't know for sure, but probably not. | ||
return nil | ||
} | ||
return vulnerabilities | ||
} | ||
|
||
func AllowInsecurePackages() { | ||
os.Setenv("NIXPKGS_ALLOW_INSECURE", "1") | ||
} | ||
|
||
func IsInsecureAllowed() bool { | ||
allowed, _ := strconv.ParseBool(os.Getenv("NIXPKGS_ALLOW_INSECURE")) | ||
return allowed | ||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😭
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah this is not the best. An alternative is to loop though all packages and check if any of them are insecure, that would make errors much slower so it's a tradeoff.