-
Notifications
You must be signed in to change notification settings - Fork 1
fix bug, remove temp data and improve scan secret for git repo function #6
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
Open
lamhaison
wants to merge
8
commits into
main
Choose a base branch
from
develop
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c497928
refactor: update .gitignore and improve docker functions for security…
lamhaison 9d287c1
add: create .gitallowed file for git-secrets pattern definitions
lamhaison c735eb2
fix: update docker-compose version and improve git-secrets patterns i…
lamhaison 42a9082
delete: remove lhs_help_incident_report function and associated docum…
lamhaison 8f47dca
feat: Implement security enhancements and CI/CD pipeline
lamhaison d2dfbe5
fix: update shfmt installation and execution in security workflow
lamhaison b90d065
fix: update shfmt installation method in security workflow
lamhaison 43d33cf
Refactor shell scripts for consistent indentation and formatting
lamhaison 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Gitleaks allowed patterns - false positives | ||
| # These are secret detection patterns used in git-secrets configuration, not actual secrets | ||
|
|
||
| BEGIN.*PRIVATE.*KEY | ||
| git secrets --add --global | ||
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,130 @@ | ||
| name: 🔒 Security & Quality Checks | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, develop] | ||
| pull_request: | ||
| branches: [main, develop] | ||
|
|
||
| jobs: | ||
| secret-scan: | ||
| name: 🔐 Secret Detection | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Run gitleaks scan | ||
| uses: gitleaks/gitleaks-action@v2 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| shellcheck: | ||
| name: 🐚 Shell Script Analysis | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Run shellcheck | ||
| uses: ludeeus/action-shellcheck@master | ||
| with: | ||
| scandir: '.' | ||
| severity: warning | ||
| format: gcc | ||
|
|
||
| shfmt: | ||
| name: 🎨 Shell Code Formatting | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install shfmt | ||
| run: | | ||
| curl -sS https://webi.sh/shfmt | sh | ||
| echo "$HOME/.local/bin" >> $GITHUB_PATH | ||
|
|
||
| - name: Check shell formatting | ||
| run: shfmt -i 4 -bn -ci -sr -d . | ||
|
|
||
| lint: | ||
| name: 📋 Linting & Validation | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Validate shell scripts | ||
| run: | | ||
| set +e | ||
| errors=0 | ||
|
|
||
| for script in $(find . -name '*.sh' -type f ! -path './.git/*' ! -path './.github/*'); do | ||
| if ! bash -n "$script" 2>&1; then | ||
| echo "❌ Syntax error in $script" | ||
| errors=$((errors + 1)) | ||
| fi | ||
| done | ||
|
|
||
| if [ $errors -gt 0 ]; then | ||
| echo "🚨 Found $errors shell scripts with syntax errors" | ||
| exit 1 | ||
| fi | ||
| echo "✅ All shell scripts have valid syntax" | ||
|
|
||
| readme-check: | ||
| name: 📖 README Validation | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Verify README content | ||
| run: | | ||
| # Check if README mentions security or has a link to SECURITY.md | ||
| if grep -q "security\|SECURITY" README.md; then | ||
| echo "✅ README references security documentation" | ||
| else | ||
| echo "⚠️ README should reference SECURITY.md" | ||
| fi | ||
|
|
||
| # Check for hardcoded credentials (basic check) | ||
| if grep -rE "password\s*=|token\s*=|secret\s*=|key\s*=" README.md | grep -v "^[[:space:]]*#" | grep -v "xxxx" | grep -v "example"; then | ||
| echo "🚨 README may contain hardcoded credentials" | ||
| exit 1 | ||
| fi | ||
| echo "✅ README validation passed" | ||
|
|
||
| security-summary: | ||
| name: 📊 Security Summary | ||
| runs-on: ubuntu-latest | ||
| needs: [secret-scan, shellcheck, shfmt, lint, readme-check] | ||
| if: always() | ||
| steps: | ||
| - name: Generate security report | ||
| run: | | ||
| echo "## 🔒 Security Check Summary" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "| Check | Status |" >> $GITHUB_STEP_SUMMARY | ||
| echo "|-------|--------|" >> $GITHUB_STEP_SUMMARY | ||
| echo "| Secret Detection | ${{ needs.secret-scan.result }} |" >> $GITHUB_STEP_SUMMARY | ||
| echo "| Shell Analysis | ${{ needs.shellcheck.result }} |" >> $GITHUB_STEP_SUMMARY | ||
| echo "| Code Formatting | ${{ needs.shfmt.result }} |" >> $GITHUB_STEP_SUMMARY | ||
| echo "| Linting | ${{ needs.lint.result }} |" >> $GITHUB_STEP_SUMMARY | ||
| echo "| README Check | ${{ needs.readme-check.result }} |" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "See [Security Policy](SECURITY.md) for details." >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| - name: Fail if security checks failed | ||
| if: | | ||
| needs.secret-scan.result == 'failure' || | ||
| needs.shellcheck.result == 'failure' || | ||
| needs.shfmt.result == 'failure' || | ||
| needs.lint.result == 'failure' || | ||
| needs.readme-check.result == 'failure' | ||
| run: | | ||
| echo "🚨 Security checks failed" | ||
| exit 1 |
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,2 +1,4 @@ | ||
| services/tmp.sh | ||
| service/temp.sh | ||
| service/temp.sh | ||
| # Testing scan secret files | ||
| test-private-key-demo.txt |
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,9 @@ | ||
| # Gitleaks ignore file for false positives | ||
| # These are secret detection patterns, not actual secrets | ||
|
|
||
| # Allow secret detection patterns in docker.sh | ||
| services/docker.sh:98:BEGIN.*PRIVATE.*KEY | ||
| services/docker.sh:*:RUN git secrets --add --global | ||
|
|
||
| # Allow patterns used for git-secrets configuration | ||
| **/*.sh:*:git secrets --add |
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,55 @@ | ||
| # Pre-commit configuration | ||
| # Install: brew install pre-commit && pre-commit install | ||
|
|
||
| repos: | ||
| # Shell script linting | ||
| - repo: https://github.com/shellcheck-py/shellcheck-py | ||
| rev: v0.9.0.5 | ||
| hooks: | ||
| - id: shellcheck | ||
| name: 🐚 Lint shell scripts | ||
| args: ['--severity=warning'] | ||
| stages: [commit] | ||
|
|
||
| # Shell script formatting | ||
| - repo: https://github.com/scop/pre-commit-shfmt | ||
| rev: v3.7.0-1 | ||
| hooks: | ||
| - id: shfmt | ||
| name: 🎨 Format shell scripts | ||
| args: ['-i', '2', '-bn', '-ci', '-sr'] | ||
| stages: [commit] | ||
|
|
||
| # Trailing whitespace and file fixes | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v4.5.0 | ||
| hooks: | ||
| - id: trailing-whitespace | ||
| name: 📝 Trim trailing whitespace | ||
| stages: [commit] | ||
| - id: end-of-file-fixer | ||
| name: 📝 Fix end of file | ||
| stages: [commit] | ||
| - id: check-yaml | ||
| name: ✅ Validate YAML | ||
| stages: [commit] | ||
| - id: check-added-large-files | ||
| name: 📦 Check for large files | ||
| args: ['--maxkb=1000'] | ||
| stages: [commit] | ||
| - id: detect-private-key | ||
| name: 🔑 Detect private keys | ||
| stages: [commit] | ||
|
|
||
| # Secret detection using gitleaks | ||
| - repo: https://github.com/gitleaks/gitleaks | ||
| rev: v8.18.2 | ||
| hooks: | ||
| - id: gitleaks | ||
| name: 🔐 Detect secrets with gitleaks | ||
| entry: gitleaks detect --source . --verbose | ||
| language: golang | ||
| stages: [commit] | ||
|
|
||
| default_language_version: | ||
| python: python3 |
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,22 @@ | ||
| { | ||
| "shellformat.effectiveLanguages": [ | ||
| "shellscript", | ||
| "dockerfile", | ||
| "dotenv", | ||
| "hosts", | ||
| "jvmoptions", | ||
| "ignore", | ||
| "gitignore", | ||
| "properties", | ||
| "spring-boot-properties", | ||
| "azcli", | ||
| "bats" | ||
| ], | ||
| "shellformat.flag": "-i 4 -bn -ci -sr", | ||
| "[shellscript]": { | ||
| "editor.defaultFormatter": "foxundermoon.shell-format", | ||
| "editor.formatOnSave": true, | ||
| "editor.tabSize": 4, | ||
| "editor.insertSpaces": 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # Change Log | ||
|
|
||
| All notable changes to this project will be documented in this file. | ||
|
|
||
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
| and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## [0.1.0] - 2025-12-15 | ||
|
|
||
| ### Added | ||
| - 🎯 Initial release with core functionality | ||
| - 🔐 Security scanning capabilities with git-secrets Docker integration | ||
| - 📦 Docker utilities (MongoDB, MySQL clients, git-secrets image builder) | ||
| - 🔧 Git utilities (peco-based tools for interactive selection) | ||
| - 🗄️ Terraform utilities | ||
| - ☸️ Kubernetes utilities | ||
| - 🎪 Service utilities (CI/CD, console editors, cURL, Git, Jenkins) | ||
| - 🔒 Security policy and documentation (SECURITY.md) | ||
| - ✅ Automated CI/CD pipeline with secret detection, shellcheck, and formatting checks | ||
| - 📋 Pre-commit hooks for local development security | ||
|
|
||
| ### Security | ||
| - 🔐 Gitleaks integration for secret detection | ||
| - 🐚 Shellcheck validation for all shell scripts | ||
| - 🎨 Code formatting standardization with shfmt | ||
| - 📝 Pre-commit hooks for preventing credential leaks | ||
| - 📖 Comprehensive security policy in SECURITY.md | ||
|
|
||
| ### Documentation | ||
| - 📚 Complete README with setup instructions | ||
| - 🔒 SECURITY.md with vulnerability reporting guidelines | ||
| - 📖 Inline documentation in functions | ||
| - 💡 Usage examples for all major functions | ||
|
|
||
| ### Quality | ||
| - ✅ Shell script linting and validation | ||
| - 🎨 Consistent code formatting | ||
| - 📋 Pre-commit configuration for development | ||
| - 🔄 GitHub Actions CI/CD pipeline | ||
|
|
||
| --- | ||
|
|
||
| ## Versioning Policy | ||
|
|
||
| - **v0.x.y**: Pre-release versions with potential breaking changes | ||
| - **v1.0.0+**: Stable versions following semantic versioning | ||
| - All releases are tagged with Git tags and available via Homebrew | ||
|
|
||
| ## Security Updates | ||
|
|
||
| For security-related changes and updates, please see [SECURITY.md](SECURITY.md). | ||
|
|
||
| ## Contributing | ||
|
|
||
| Before contributing, please review: | ||
| 1. [SECURITY.md](SECURITY.md) - Security policies | ||
| 2. [README.md](README.md) - Project overview | ||
| 3. Our CI/CD checks run automatically on pull requests | ||
|
|
||
| ## Support | ||
|
|
||
| For issues or questions: | ||
| 1. Check existing issues and discussions | ||
| 2. Review [SECURITY.md](SECURITY.md) for security concerns | ||
| 3. See GitHub Actions logs for CI/CD failures |
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
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.
The
.gitallowedentryBEGIN.*PRIVATE.*KEYeffectively allows all private key blocks to bypassgit-secretsdetection, so any real private key committed to this repository will not be flagged. This weakens your secret-scanning control and can lead to unnoticed exposure of TLS, SSH, or other private keys to anyone with repository access. Consider removing or drastically narrowing this allow pattern so only the specific non-sensitive example lines are exempted.