Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

feat: Add Gitleaks Secret Detection for Comprehensive Credential Scanning (#931)

LearningCircuit547e947f28d8
diff --git a/.github/workflows/container-security.yml b/.github/workflows/container-security.yml
new file mode 100644
index 0000000000..8205726dcf
--- /dev/null
+++ b/.github/workflows/container-security.yml
@@ -0,0 +1,114 @@
+name: Container Security
+
+on:
+ push:
+ branches: [ main, dev ]
+ pull_request:
+ branches: [ main, dev ]
+ workflow_dispatch:
+ schedule:
+ # Run container security scan daily at 4 AM UTC
+ - cron: '0 4 * * *'
+
+jobs:
+ trivy-scan:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ security-events: write
+ actions: read
+ packages: write
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v5
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Build Docker image for scanning
+ uses: docker/build-push-action@v6
+ with:
+ context: .
+ push: false
+ load: true
+ tags: local-deep-research:scan
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+
+ - name: Run Trivy vulnerability scanner
+ uses: aquasecurity/trivy-action@master
+ with:
+ image-ref: local-deep-research:scan
+ format: 'sarif'
+ output: 'trivy-results.sarif'
+ severity: 'CRITICAL,HIGH,MEDIUM'
+ scan-type: 'image'
+ scan-ref: '.'
+ list-all-pkgs: true
+
+ - name: Upload Trivy scan results to GitHub Security tab
+ uses: github/codeql-action/upload-sarif@v3
+ if: always()
+ with:
+ sarif_file: 'trivy-results.sarif'
+ category: container-security
+
+ - name: Upload Trivy scan results as artifact
+ uses: actions/upload-artifact@v4
+ if: always()
+ with:
+ name: trivy-scan-results
+ path: trivy-results.sarif
+ retention-days: 30
+
+ - name: Display Trivy summary
+ if: always()
+ run: |
+ echo "## Container Security Scan Summary" >> $GITHUB_STEP_SUMMARY
+ echo "" >> $GITHUB_STEP_SUMMARY
+ if [ -f trivy-results.sarif ]; then
+ echo "✅ Trivy scan completed - Results available in Security tab" >> $GITHUB_STEP_SUMMARY
+ echo "📊 Scan results uploaded as artifact" >> $GITHUB_STEP_SUMMARY
+ else
+ echo "❌ Trivy scan failed" >> $GITHUB_STEP_SUMMARY
+ fi
+
+ # Additional job for Dockerfile security analysis
+ dockerfile-scan:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v5
+
+ - name: Run Trivy config scan on Dockerfile
+ uses: aquasecurity/trivy-action@master
+ with:
+ scan-type: 'config'
+ scan-ref: '.'
+ format: 'sarif'
+ output: 'trivy-config-results.sarif'
+ hide-progress: true
+
+ - name: Upload Trivy config scan results
+ uses: actions/upload-artifact@v4
+ if: always()
+ with:
+ name: trivy-config-results
+ path: trivy-config-results.sarif
+ retention-days: 30
+
+ - name: Display config scan summary
+ if: always()
+ run: |
+ echo "## Docker Configuration Security Analysis" >> $GITHUB_STEP_SUMMARY
+ echo "" >> $GITHUB_STEP_SUMMARY
+ if [ -f trivy-config-results.sarif ]; then
+ echo "✅ Docker configuration analysis completed" >> $GITHUB_STEP_SUMMARY
+ echo "📋 Check for Docker best practices and security misconfigurations" >> $GITHUB_STEP_SUMMARY
+ else
+ echo "❌ Docker configuration scan failed" >> $GITHUB_STEP_SUMMARY
+ fi
diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml
index 3709c22061..39f53a564b 100644
--- a/.github/workflows/docker-publish.yml
+++ b/.github/workflows/docker-publish.yml
@@ -35,6 +35,33 @@ jobs:
type=semver,pattern={{major}}.{{minor}}
latest
+ - name: Build Docker image for security scan
+ uses: docker/build-push-action@v6
+ with:
+ context: .
+ push: false
+ load: true
+ tags: local-deep-research:security-scan
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+
+ - name: Run Trivy security scan before push
+ uses: aquasecurity/trivy-action@master
+ with:
+ image-ref: local-deep-research:security-scan
+ format: 'sarif'
+ output: 'trivy-release-scan.sarif'
+ severity: 'CRITICAL,HIGH'
+ exit-code: '1'
+
+ - name: Upload Trivy scan results from release
+ uses: actions/upload-artifact@v4
+ if: always()
+ with:
+ name: trivy-release-scan
+ path: trivy-release-scan.sarif
+ retention-days: 90
+
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
@@ -42,3 +69,5 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
diff --git a/.github/workflows/file-whitelist-check.yml b/.github/workflows/file-whitelist-check.yml
index 5593190583..e7c21a27fc 100644
--- a/.github/workflows/file-whitelist-check.yml
+++ b/.github/workflows/file-whitelist-check.yml
@@ -34,6 +34,7 @@ jobs:
"\.flake8$"
"\.ipynb$"
"\.template$"
+ "\.toml$"
"^\.gitignore$"
"^\.gitkeep$"
".*\.gitkeep$"
@@ -42,6 +43,7 @@ jobs:
"^\.isort\.cfg$"
"^\.coveragerc$"
"^\.secrets\.baseline$"
+ "^\.gitleaks\.toml$"
"^pytest\.ini$"
"^LICENSE$"
"^README$"
diff --git a/.github/workflows/gitleaks.yml b/.github/workflows/gitleaks.yml
new file mode 100644
index 0000000000..a6b6c1626a
--- /dev/null
+++ b/.github/workflows/gitleaks.yml
@@ -0,0 +1,32 @@
+name: Gitleaks Secret Detection
+
+on:
+ push:
+ branches: [ main, dev ]
+ pull_request:
+ branches: [ main, dev ]
+ workflow_dispatch:
+ schedule:
+ # Run secret scan daily at 3 AM UTC
+ - cron: '0 3 * * *'
+
+jobs:
+ gitleaks:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ security-events: write
+ actions: read
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v5
+ with:
+ fetch-depth: 0 # Fetch full history for comprehensive secret scanning
+
+ - name: Run Gitleaks Secret Scanner
+ uses: gitleaks/gitleaks-action@v2
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GITHUB_USERNAME: ${{ github.actor }}
+ GITHUB_REPOSITORY: ${{ github.repository }}
diff --git a/.gitignore b/.gitignore
index 5cee180932..e059101ae7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -51,6 +51,10 @@
!.pre-commit-hooks/*.py
!.pre-commit-hooks/*.sh
+# Allow security configuration files
+!.gitleaks.toml
+!.semgrepignore
+!.trivyignore
# Block all other dot files/folders
.*
diff --git a/.gitleaks.toml b/.gitleaks.toml
new file mode 100644
index 0000000000..c039a35b0c
--- /dev/null
+++ b/.gitleaks.toml
@@ -0,0 +1,112 @@
+title = "Gitleaks Configuration for Local Deep Research"
+
+# Extend default rules with custom ones
+[extend]
+useDefault = true
+
+# Custom rules for this repository
+[[rules]]
+description = "GitHub personal access token"
+id = "github-pat"
+regex = '''ghp_[a-zA-Z0-9]{36}'''
+keywords = ["ghp_"]
+
+[[rules]]
+description = "GitHub app token"
+id = "github-app-token"
+regex = '''(ghu|ghs|ghr)_[a-zA-Z0-9]{36}'''
+keywords = ["ghu_", "ghs_", "ghr_"]
+
+[[rules]]
+description = "Google API key"
+id = "google-api-key"
+regex = '''AIza[0-9A-Za-z_-]{35}'''
+keywords = ["AIza"]
+
+[[rules]]
+description = "Brave Search API key"
+id = "brave-api-key"
+regex = '''BS[a-zA-Z0-9_-]{32}'''
+keywords = ["BS"]
+
+[[rules]]
+description = "SERPAPI key"
+id = "serpapi-key"
+regex = '''[a-zA-Z0-9]{64}'''
+keywords = ["serpapi"]
+
+[[rules]]
+description = "Tavily API key"
+id = "tavily-api-key"
+regex = '''tvly-[a-zA-Z0-9_-]{40}'''
+keywords = ["tvly-"]
+
+[[rules]]
+description = "SQLCipher database key"
+id = "sqlcipher-key"
+regex = '''PRAGMA key = ['"][a-zA-Z0-9/+]{44}['"]'''
+keywords = ["PRAGMA key"]
+
+[[rules]]
+description = "Generic private key"
+id = "private-key"
+regex = '''-----BEGIN (RSA |OPENSSH |DSA |EC |PGP )?PRIVATE KEY-----'''
+keywords = ["BEGIN PRIVATE KEY", "BEGIN RSA PRIVATE KEY", "BEGIN OPENSSH PRIVATE KEY"]
+
+[[rules]]
+description = "Generic secret/password pattern"
+id = "generic-secret"
+regex = '''(?i)(password|secret|token|key)\s*[:=]\s*['"]?[a-zA-Z0-9_\-@#$%^&*]{8,}['"]?'''
+keywords = ["password", "secret", "token", "key"]
+
+# Allowlist - exclude common false positives
+[allowlist]
+description = "Global allowlist"
+paths = [
+ '''\.git''',
+ '''\.venv''',
+ '''node_modules''',
+ '''\.pytest_cache''',
+ '''__pycache__''',
+ '''coverage''',
+ '''\.coverage''',
+ '''test_results''',
+ '''screenshots''',
+ '''build''',
+ '''dist''',
+ '''\.mypy_cache''',
+ '''\.tox''',
+ '''tests/.*\.py$''',
+ '''examples/.*\.py$''',
+ '''.*test.*\.py$''',
+ '''.*example.*\.py$''',
+ '''mock.*\.py$''',
+ '''fixture.*\.py$'''
+]
+files = [
+ "\\.env\\.example$",
+ "\\.env\\.template$",
+ "config\\.example\\..*$",
+ "docker-compose\\.example\\.yml$"
+]
+commits = [''']
+ (?i)(placeholder|example|test|mock|fake|dummy).*key
+''']
+
+# Target specific files for scanning
+[target]
+paths = [
+ '''src/''',
+ '''scripts/''',
+ '''docs/''',
+ '''\.py$''',
+ '''\.js$''',
+ '''\.ts$''',
+ '''\.json$''',
+ '''\.yml$''',
+ '''\.yaml$''',
+ '''\.env$''',
+ '''\.sh$''',
+ '''Dockerfile.*''',
+ '''docker-compose.*''',
+]
diff --git a/.pre-commit-hooks/file-whitelist-check.sh b/.pre-commit-hooks/file-whitelist-check.sh
index be49997613..a6847c5fd0 100755
--- a/.pre-commit-hooks/file-whitelist-check.sh
+++ b/.pre-commit-hooks/file-whitelist-check.sh
@@ -17,6 +17,7 @@ ALLOWED_PATTERNS=(
"\.flake8$"
"\.ipynb$"
"\.template$"
+ "\.toml$"
"^\.gitignore$"
"^\.gitkeep$"
".*\.gitkeep$"
@@ -25,6 +26,10 @@ ALLOWED_PATTERNS=(
"^\.isort\.cfg$"
"^\.coveragerc$"
"^\.secrets\.baseline$"
+ "^\.gitleaks\.toml$"
+ "^pyproject\.toml$"
+ "^\.semgrepignore$"
+ "^\.trivyignore$"
"^pytest\.ini$"
"^LICENSE$"
"^README$"