Upload 3 files
Browse files- .github/workflows/bandit.yml +42 -0
- .github/workflows/sync-huggingface.yml +32 -3
- .github/workflows/test-sec.yml +110 -0
.github/workflows/bandit.yml
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Bandit
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
branches: ["main"]
|
| 6 |
+
pull_request:
|
| 7 |
+
branches: ["main"]
|
| 8 |
+
schedule:
|
| 9 |
+
- cron: "40 13 * * 4"
|
| 10 |
+
|
| 11 |
+
permissions:
|
| 12 |
+
contents: read
|
| 13 |
+
security-events: write
|
| 14 |
+
actions: read
|
| 15 |
+
|
| 16 |
+
jobs:
|
| 17 |
+
bandit:
|
| 18 |
+
runs-on: ubuntu-latest
|
| 19 |
+
|
| 20 |
+
steps:
|
| 21 |
+
- uses: actions/checkout@v4
|
| 22 |
+
|
| 23 |
+
- name: Set up Python
|
| 24 |
+
uses: actions/setup-python@v5
|
| 25 |
+
with:
|
| 26 |
+
python-version: "3.x"
|
| 27 |
+
|
| 28 |
+
- name: Install Bandit
|
| 29 |
+
run: python -m pip install --upgrade bandit[toml]
|
| 30 |
+
|
| 31 |
+
- name: Run Bandit
|
| 32 |
+
run: |
|
| 33 |
+
bandit -r . \
|
| 34 |
+
-f sarif \
|
| 35 |
+
-o bandit.sarif \
|
| 36 |
+
--exclude .git,__pycache__,.tox,.eggs,*.egg
|
| 37 |
+
|
| 38 |
+
- name: Upload SARIF
|
| 39 |
+
if: always()
|
| 40 |
+
uses: github/codeql-action/upload-sarif@v3
|
| 41 |
+
with:
|
| 42 |
+
sarif_file: bandit.sarif
|
.github/workflows/sync-huggingface.yml
CHANGED
|
@@ -4,6 +4,7 @@ on:
|
|
| 4 |
push:
|
| 5 |
branches:
|
| 6 |
- main
|
|
|
|
| 7 |
workflow_dispatch:
|
| 8 |
inputs:
|
| 9 |
sync_direction:
|
|
@@ -19,7 +20,7 @@ permissions:
|
|
| 19 |
contents: write
|
| 20 |
|
| 21 |
concurrency:
|
| 22 |
-
group: repo-sync-
|
| 23 |
cancel-in-progress: false
|
| 24 |
|
| 25 |
jobs:
|
|
@@ -34,6 +35,14 @@ jobs:
|
|
| 34 |
with:
|
| 35 |
fetch-depth: 0
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
- name: Configure Git identity
|
| 38 |
run: |
|
| 39 |
git config --global user.name "github-actions[bot]"
|
|
@@ -45,10 +54,19 @@ jobs:
|
|
| 45 |
HF_USERNAME: ${{ secrets.HF_USERNAME }}
|
| 46 |
run: |
|
| 47 |
REPO_NAME="${GITHUB_REPOSITORY#*/}"
|
|
|
|
| 48 |
git remote remove huggingface 2>/dev/null || true
|
| 49 |
git remote add huggingface "https://${HF_USERNAME}:${HF_TOKEN}@huggingface.co/spaces/${HF_USERNAME}/${REPO_NAME}"
|
| 50 |
|
| 51 |
-
- name:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
run: |
|
| 53 |
git push huggingface main:main --force-with-lease
|
| 54 |
|
|
@@ -58,6 +76,16 @@ jobs:
|
|
| 58 |
runs-on: ubuntu-latest
|
| 59 |
|
| 60 |
steps:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
- name: Checkout GitHub repository
|
| 62 |
uses: actions/checkout@v4
|
| 63 |
with:
|
|
@@ -75,6 +103,7 @@ jobs:
|
|
| 75 |
HF_USERNAME: ${{ secrets.HF_USERNAME }}
|
| 76 |
run: |
|
| 77 |
REPO_NAME="${GITHUB_REPOSITORY#*/}"
|
|
|
|
| 78 |
git remote remove huggingface 2>/dev/null || true
|
| 79 |
git remote add huggingface "https://${HF_USERNAME}:${HF_TOKEN}@huggingface.co/spaces/${HF_USERNAME}/${REPO_NAME}"
|
| 80 |
|
|
@@ -89,4 +118,4 @@ jobs:
|
|
| 89 |
|
| 90 |
- name: Push merged state to GitHub
|
| 91 |
run: |
|
| 92 |
-
git push origin main
|
|
|
|
| 4 |
push:
|
| 5 |
branches:
|
| 6 |
- main
|
| 7 |
+
|
| 8 |
workflow_dispatch:
|
| 9 |
inputs:
|
| 10 |
sync_direction:
|
|
|
|
| 20 |
contents: write
|
| 21 |
|
| 22 |
concurrency:
|
| 23 |
+
group: repo-sync-main
|
| 24 |
cancel-in-progress: false
|
| 25 |
|
| 26 |
jobs:
|
|
|
|
| 35 |
with:
|
| 36 |
fetch-depth: 0
|
| 37 |
|
| 38 |
+
- name: Validate required secrets
|
| 39 |
+
env:
|
| 40 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 41 |
+
HF_USERNAME: ${{ secrets.HF_USERNAME }}
|
| 42 |
+
run: |
|
| 43 |
+
test -n "$HF_TOKEN" || (echo "HF_TOKEN is missing" && exit 1)
|
| 44 |
+
test -n "$HF_USERNAME" || (echo "HF_USERNAME is missing" && exit 1)
|
| 45 |
+
|
| 46 |
- name: Configure Git identity
|
| 47 |
run: |
|
| 48 |
git config --global user.name "github-actions[bot]"
|
|
|
|
| 54 |
HF_USERNAME: ${{ secrets.HF_USERNAME }}
|
| 55 |
run: |
|
| 56 |
REPO_NAME="${GITHUB_REPOSITORY#*/}"
|
| 57 |
+
|
| 58 |
git remote remove huggingface 2>/dev/null || true
|
| 59 |
git remote add huggingface "https://${HF_USERNAME}:${HF_TOKEN}@huggingface.co/spaces/${HF_USERNAME}/${REPO_NAME}"
|
| 60 |
|
| 61 |
+
- name: Verify remotes
|
| 62 |
+
run: |
|
| 63 |
+
git remote -v | sed 's#https://.*@huggingface.co#https://***@huggingface.co#g'
|
| 64 |
+
|
| 65 |
+
- name: Fetch Hugging Face state
|
| 66 |
+
run: |
|
| 67 |
+
git fetch huggingface main || true
|
| 68 |
+
|
| 69 |
+
- name: Push GitHub main to Hugging Face
|
| 70 |
run: |
|
| 71 |
git push huggingface main:main --force-with-lease
|
| 72 |
|
|
|
|
| 76 |
runs-on: ubuntu-latest
|
| 77 |
|
| 78 |
steps:
|
| 79 |
+
- name: Validate required secrets
|
| 80 |
+
env:
|
| 81 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 82 |
+
HF_USERNAME: ${{ secrets.HF_USERNAME }}
|
| 83 |
+
GH_PAT: ${{ secrets.GH_PAT }}
|
| 84 |
+
run: |
|
| 85 |
+
test -n "$HF_TOKEN" || (echo "HF_TOKEN is missing" && exit 1)
|
| 86 |
+
test -n "$HF_USERNAME" || (echo "HF_USERNAME is missing" && exit 1)
|
| 87 |
+
test -n "$GH_PAT" || (echo "GH_PAT is missing" && exit 1)
|
| 88 |
+
|
| 89 |
- name: Checkout GitHub repository
|
| 90 |
uses: actions/checkout@v4
|
| 91 |
with:
|
|
|
|
| 103 |
HF_USERNAME: ${{ secrets.HF_USERNAME }}
|
| 104 |
run: |
|
| 105 |
REPO_NAME="${GITHUB_REPOSITORY#*/}"
|
| 106 |
+
|
| 107 |
git remote remove huggingface 2>/dev/null || true
|
| 108 |
git remote add huggingface "https://${HF_USERNAME}:${HF_TOKEN}@huggingface.co/spaces/${HF_USERNAME}/${REPO_NAME}"
|
| 109 |
|
|
|
|
| 118 |
|
| 119 |
- name: Push merged state to GitHub
|
| 120 |
run: |
|
| 121 |
+
git push origin main
|
.github/workflows/test-sec.yml
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: CI
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
branches: ["main"]
|
| 6 |
+
pull_request:
|
| 7 |
+
branches: ["main"]
|
| 8 |
+
|
| 9 |
+
permissions:
|
| 10 |
+
contents: read
|
| 11 |
+
|
| 12 |
+
jobs:
|
| 13 |
+
test-and-secure:
|
| 14 |
+
runs-on: ubuntu-latest
|
| 15 |
+
|
| 16 |
+
env:
|
| 17 |
+
ALLOW_DEV_SALT: "true"
|
| 18 |
+
|
| 19 |
+
steps:
|
| 20 |
+
- name: Checkout repository
|
| 21 |
+
uses: actions/checkout@v4
|
| 22 |
+
|
| 23 |
+
- name: Set up Python
|
| 24 |
+
uses: actions/setup-python@v5
|
| 25 |
+
with:
|
| 26 |
+
python-version: "3.13"
|
| 27 |
+
|
| 28 |
+
- name: Cache pip dependencies
|
| 29 |
+
uses: actions/cache@v4
|
| 30 |
+
with:
|
| 31 |
+
path: ~/.cache/pip
|
| 32 |
+
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
|
| 33 |
+
restore-keys: |
|
| 34 |
+
${{ runner.os }}-pip-
|
| 35 |
+
|
| 36 |
+
- name: Install dependencies
|
| 37 |
+
run: |
|
| 38 |
+
python -m pip install --upgrade pip
|
| 39 |
+
python -m pip install -r requirements.txt
|
| 40 |
+
python -m pip install pytest ruff bandit pip-audit
|
| 41 |
+
|
| 42 |
+
- name: Lint with Ruff
|
| 43 |
+
run: ruff check .
|
| 44 |
+
|
| 45 |
+
- name: Check formatting with Ruff
|
| 46 |
+
run: ruff format --check .
|
| 47 |
+
|
| 48 |
+
- name: Security scan with Bandit
|
| 49 |
+
run: |
|
| 50 |
+
bandit -r osint_core/ -ll
|
| 51 |
+
|
| 52 |
+
- name: Audit Python dependencies
|
| 53 |
+
run: |
|
| 54 |
+
pip-audit -r requirements.txt
|
| 55 |
+
|
| 56 |
+
- name: Run tests
|
| 57 |
+
run: |
|
| 58 |
+
pytest -v --tb=short
|
| 59 |
+
|
| 60 |
+
drift-guard:
|
| 61 |
+
runs-on: ubuntu-latest
|
| 62 |
+
needs: test-and-secure
|
| 63 |
+
|
| 64 |
+
steps:
|
| 65 |
+
- name: Checkout repository
|
| 66 |
+
uses: actions/checkout@v4
|
| 67 |
+
|
| 68 |
+
- name: Set up Python
|
| 69 |
+
uses: actions/setup-python@v5
|
| 70 |
+
with:
|
| 71 |
+
python-version: "3.13"
|
| 72 |
+
|
| 73 |
+
- name: Install YAML parser
|
| 74 |
+
run: |
|
| 75 |
+
python -m pip install --upgrade pip
|
| 76 |
+
python -m pip install PyYAML
|
| 77 |
+
|
| 78 |
+
- name: Verify critical files exist
|
| 79 |
+
run: |
|
| 80 |
+
test -f osint_core/intent.py
|
| 81 |
+
test -f osint_core/policy.py
|
| 82 |
+
test -f osint_core/validators.py
|
| 83 |
+
|
| 84 |
+
- name: Prevent forbidden tools from entering repo
|
| 85 |
+
run: |
|
| 86 |
+
if git grep -n -I -E "nmap|masscan|sqlmap|metasploit" -- . \
|
| 87 |
+
':(exclude).github/workflows/*' \
|
| 88 |
+
':(exclude)README.md' \
|
| 89 |
+
':(exclude)docs/*'; then
|
| 90 |
+
echo "Forbidden tooling detected"
|
| 91 |
+
exit 1
|
| 92 |
+
fi
|
| 93 |
+
|
| 94 |
+
- name: Enforce passive-first invariant
|
| 95 |
+
run: |
|
| 96 |
+
if git grep -n -I "requests.get(" -- osint_core/ | grep -v "authorized"; then
|
| 97 |
+
echo "Potential unauthorized outbound request"
|
| 98 |
+
exit 1
|
| 99 |
+
fi
|
| 100 |
+
|
| 101 |
+
- name: Validate YAML integrity
|
| 102 |
+
run: |
|
| 103 |
+
python -c "import yaml; yaml.safe_load(open('data/sources.yaml', encoding='utf-8'))"
|
| 104 |
+
|
| 105 |
+
- name: Check for raw indicator leakage
|
| 106 |
+
run: |
|
| 107 |
+
if git grep -n -I -E "example\.com|@gmail\.com|192\.168\." -- osint_core/; then
|
| 108 |
+
echo "Possible raw indicator leakage"
|
| 109 |
+
exit 1
|
| 110 |
+
fi
|