Files
NexQuant/.github/workflows/security.yml
T
TPTBusiness 2cec08bc91 feat: add daily log rotation, llama health wait, factor auto-fixer, and README updates
- Add rdagent/log/daily_log.py: daily-rotating structured logs per command
  (fin_quant, strategies, evaluate, parallel) with loguru; all.log combined sink
- predix.py: route TeeWriter output to logs/YYYY-MM-DD/ instead of root dir;
  wrap quant() and evaluate() in daily_log.session() for start/stop/duration tracking
- rdagent/app/cli.py: fin_quant_cli waits for llama.cpp /health endpoint before
  starting pipeline (up to 300 s); daily_log integration for fin_quant,
  generate_strategies, eval_all, parallel commands
- scripts/predix_gen_strategies_real_bt.py: daily_log integration with
  per-strategy ACCEPTED/REJECTED entries and summary on completion
- rdagent/components/coder/factor_coder/auto_fixer.py: new module that patches
  common LLM-generated factor issues (min_periods, inf/NaN, groupby.transform,
  MultiIndex corrections)
- rdagent/components/coder/factor_coder/prompts.yaml: add critical rules for
  EURUSD 1-min intraday factors (min_periods, inf handling, groupby, date range)
- README.md: document --reasoning off and --n-gpu-layers 28 for llama-server;
  explain VRAM constraints when Ollama is running alongside llama.cpp
- .bandit.yml: suppress B615 (HuggingFace unsafe download) for RL benchmark files

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-16 07:20:08 +02:00

136 lines
3.7 KiB
YAML

name: Security Scan
on:
push:
branches: [ master, develop ]
pull_request:
branches: [ master ]
schedule:
# Weekly on Monday at 6:00 UTC
- cron: '0 6 * * 1'
jobs:
security:
name: Security Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Cache pip dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-security-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-security-
- name: Install security tools
run: |
python -m pip install --upgrade pip
pip install bandit safety
- name: Run Bandit (code security)
run: |
echo "=== Running Bandit Security Scan ==="
bandit \
-c .bandit.yml \
-r rdagent/ \
-f json \
-o bandit-report.json \
--exit-zero || true
# Show summary
bandit -c .bandit.yml -r rdagent/ -ll || true
- name: Upload Bandit report
uses: actions/upload-artifact@v4
if: always()
with:
name: bandit-security-report
path: bandit-report.json
retention-days: 30
- name: Check dependencies for vulnerabilities
run: |
echo "=== Checking Dependencies for Vulnerabilities ==="
safety check --json || {
echo "::warning::Some dependencies have known vulnerabilities"
echo "Please review and update dependencies."
exit 0 # Non-blocking
}
- name: Check for exposed secrets
run: |
echo "=== Scanning for Exposed Secrets ==="
# Check for common secret patterns
PATTERNS=(
"api_key\s*=\s*['\"][^'\"]+['\"]"
"secret\s*=\s*['\"][^'\"]+['\"]"
"password\s*=\s*['\"][^'\"]+['\"]"
"token\s*=\s*['\"][^'\"]+['\"]"
"PRIVATE.KEY"
"BEGIN RSA PRIVATE KEY"
)
FOUND_SECRETS=0
for pattern in "${PATTERNS[@]}"; do
if grep -rInE "$pattern" --include='*.py' --include='*.yml' --include='*.yaml' --include='*.json' . | \
grep -v '.git' | \
grep -v 'test/' | \
grep -v 'example' | \
grep -v '# ' | \
grep -v 'os.environ' | \
grep -v 'getenv' | \
grep -v 'argparse'; then
FOUND_SECRETS=1
fi
done
if [ $FOUND_SECRETS -eq 1 ]; then
echo "::error::Potential secrets exposure detected!"
echo "Please review the output above and remove any hardcoded credentials."
echo "Use environment variables or .env files instead."
exit 1
fi
echo "✓ No exposed secrets found"
- name: Verify closed-source files not committed
run: |
echo "=== Verifying No Closed-Source Assets Committed ==="
CLOSED_PATTERNS=(
"git_ignore_folder/"
"results/"
".env"
"models/local/"
"prompts/local/"
"rdagent/scenarios/qlib/local/"
"*.db"
"*.log"
)
FOUND_CLOSED=0
for pattern in "${CLOSED_PATTERNS[@]}"; do
if git ls-files | grep -q "$pattern"; then
echo "::error::Found closed-source asset: $pattern"
FOUND_CLOSED=1
fi
done
if [ $FOUND_CLOSED -eq 1 ]; then
echo "CRITICAL: Closed-source assets must not be committed to the repository!"
echo "Please remove them and add to .gitignore if needed."
exit 1
fi
echo "✓ No closed-source assets found"