-
Notifications
You must be signed in to change notification settings - Fork 0
fix(security): disable docker-postgres on kyber #1506
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b077f65
fix(ci): resolve nix format, shell inline-check, and docker cache fai…
shunkakinoki 1f3b409
test: add spec for secure-dotenv.sh
shunkakinoki 9342ccc
Merge branch 'main' into twinkly-dazzling-stroustrup
shunkakinoki 1b69c21
fix(nix): resolve statix empty-pattern lint and format drift
shunkakinoki 83525b0
fix(security): disable docker-postgres on kyber to prevent cryptomine…
shunkakinoki 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| { ... }: | ||
| { | ||
| _: { | ||
| home.file.".mempalace/config.json" = { | ||
| source = ./config.json; | ||
| force = true; | ||
|
|
||
This file contains hidden or 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 hidden or 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,17 @@ | ||
| #!/usr/bin/env bash | ||
| # @find@ and @stat@ are substituted by pkgs.replaceVars. | ||
| set -euo pipefail | ||
|
|
||
| HOME_DIR="$1" | ||
|
|
||
| @find@ "${HOME_DIR}" \ | ||
| -maxdepth 4 \ | ||
| \( -name '.env' -o -name '.env.*' -o -name '*.env' \) \ | ||
| 2>/dev/null | while IFS= read -r f; do | ||
| if [ -f "$f" ] && [ ! -L "$f" ]; then | ||
| current=$(@stat@ -c '%a' "$f") | ||
| if [ "$current" != "600" ]; then | ||
| chmod 600 "$f" | ||
| fi | ||
| fi | ||
| done | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,114 @@ | ||
| #!/usr/bin/env bash | ||
| # shellcheck disable=SC2329,SC2016 | ||
|
|
||
| Describe 'home-manager/modules/secure-dotenv/secure-dotenv.sh' | ||
| SCRIPT="$PWD/home-manager/modules/secure-dotenv/secure-dotenv.sh" | ||
|
|
||
| Describe 'script properties' | ||
| It 'uses bash shebang' | ||
| When run bash -c "head -1 '$SCRIPT'" | ||
| The output should include '#!/usr/bin/env bash' | ||
| End | ||
|
|
||
| It 'uses strict mode' | ||
| When run bash -c "head -5 '$SCRIPT'" | ||
| The output should include 'set -euo pipefail' | ||
| End | ||
|
|
||
| It 'passes bash syntax check after stripping placeholders' | ||
| When run bash -c "sed 's|@[A-Za-z_][A-Za-z0-9_]*@|/usr/bin/test|g' '$SCRIPT' | bash -n" | ||
| The status should be success | ||
| End | ||
| End | ||
|
|
||
| Describe 'placeholder substitutions' | ||
| It 'references @find@' | ||
| When run bash -c "grep '@find@' '$SCRIPT'" | ||
| The output should include '@find@' | ||
| End | ||
|
|
||
| It 'references @stat@' | ||
| When run bash -c "grep '@stat@' '$SCRIPT'" | ||
| The output should include '@stat@' | ||
| End | ||
| End | ||
|
|
||
| Describe 'requires HOME_DIR argument' | ||
| It 'reads HOME_DIR from $1' | ||
| When run bash -c "grep 'HOME_DIR=.\$1.' '$SCRIPT'" | ||
| The output should include 'HOME_DIR="$1"' | ||
| End | ||
| End | ||
|
|
||
| Describe 'functional behavior' | ||
| setup() { | ||
| TEST_HOME="$(mktemp -d)" | ||
| # Create .env files with non-600 permissions | ||
| echo "SECRET=value" >"$TEST_HOME/.env" | ||
| chmod 644 "$TEST_HOME/.env" | ||
|
|
||
| mkdir -p "$TEST_HOME/subdir" | ||
| echo "DB_URL=postgres://..." >"$TEST_HOME/subdir/.env.local" | ||
| chmod 755 "$TEST_HOME/subdir/.env.local" | ||
|
|
||
| echo "KEY=val" >"$TEST_HOME/app.env" | ||
| chmod 644 "$TEST_HOME/app.env" | ||
|
|
||
| # Create a file already at 600 | ||
| echo "OK=true" >"$TEST_HOME/.env.safe" | ||
| chmod 600 "$TEST_HOME/.env.safe" | ||
|
|
||
| # Create a symlink (should be skipped) | ||
| ln -s "$TEST_HOME/.env" "$TEST_HOME/.env.link" | ||
|
|
||
| # Preprocess the script, replacing placeholders with real commands | ||
| PROCESSED_SCRIPT="$TEST_HOME/secure-dotenv-test.sh" | ||
| sed \ | ||
| -e "s|@find@|$(command -v find)|g" \ | ||
| -e "s|@stat@|$(command -v stat)|g" \ | ||
| "$SCRIPT" >"$PROCESSED_SCRIPT" | ||
| chmod +x "$PROCESSED_SCRIPT" | ||
|
|
||
| export TEST_HOME PROCESSED_SCRIPT | ||
| } | ||
| cleanup() { | ||
| rm -rf "$TEST_HOME" | ||
| unset TEST_HOME PROCESSED_SCRIPT | ||
| } | ||
| Before 'setup' | ||
| After 'cleanup' | ||
|
|
||
| It 'changes .env from 644 to 600' | ||
| When run bash "$PROCESSED_SCRIPT" "$TEST_HOME" | ||
|
Contributor
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. P2: The Prompt for AI agents |
||
| The status should be success | ||
| End | ||
|
|
||
| It 'changes .env.local from 755 to 600' | ||
| When run bash -c "bash '$PROCESSED_SCRIPT' '$TEST_HOME' && stat -c '%a' '$TEST_HOME/subdir/.env.local'" | ||
| The output should equal '600' | ||
| End | ||
|
|
||
| It 'changes app.env from 644 to 600' | ||
| When run bash -c "bash '$PROCESSED_SCRIPT' '$TEST_HOME' && stat -c '%a' '$TEST_HOME/app.env'" | ||
| The output should equal '600' | ||
| End | ||
|
|
||
| It 'leaves already-600 files unchanged' | ||
| When run bash -c "bash '$PROCESSED_SCRIPT' '$TEST_HOME' && stat -c '%a' '$TEST_HOME/.env.safe'" | ||
| The output should equal '600' | ||
| End | ||
|
|
||
| It 'does not follow symlinks' | ||
| When run bash -c "bash '$PROCESSED_SCRIPT' '$TEST_HOME' && test -L '$TEST_HOME/.env.link' && echo 'still-symlink'" | ||
| The output should equal 'still-symlink' | ||
| End | ||
| End | ||
|
|
||
| Describe 'depth limit' | ||
| It 'uses maxdepth 4' | ||
| When run bash -c "grep 'maxdepth 4' '$SCRIPT'" | ||
| The output should include 'maxdepth 4' | ||
| End | ||
| End | ||
|
|
||
| End | ||
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.
To robustly handle filenames that might contain spaces or newlines, it is recommended to use
-print0withfindandread -d ''. This follows the organization's general rule for robustly parsing command output. Additionally, using-type fin thefindcommand is more efficient and allows removing the manual file type check inside the loop.References