-
-
Notifications
You must be signed in to change notification settings - Fork 0
Integration PR #9–#12: CyberAi architecture merged, governance conflicts documented #14
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
base: main
Are you sure you want to change the base?
Changes from all commits
e2b2695
df54a0e
7be49ea
ae94131
6f36ae8
a52fcf6
eda2625
7d6717b
b769016
6648838
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,349 @@ | ||||||||||||||
| name: CyberAi Super Workflow | ||||||||||||||
|
|
||||||||||||||
| on: | ||||||||||||||
| push: | ||||||||||||||
| branches: [main] | ||||||||||||||
| pull_request: | ||||||||||||||
| branches: [main] | ||||||||||||||
| schedule: | ||||||||||||||
| # Run daily at 2 AM UTC | ||||||||||||||
| - cron: '0 2 * * *' | ||||||||||||||
| workflow_dispatch: | ||||||||||||||
| inputs: | ||||||||||||||
| mode: | ||||||||||||||
| description: 'Execution mode' | ||||||||||||||
| required: false | ||||||||||||||
| default: 'dry-run' | ||||||||||||||
| type: choice | ||||||||||||||
| options: | ||||||||||||||
| - dry-run | ||||||||||||||
| - production | ||||||||||||||
| audit_depth: | ||||||||||||||
| description: 'Audit depth' | ||||||||||||||
| required: false | ||||||||||||||
| default: 'standard' | ||||||||||||||
| type: choice | ||||||||||||||
| options: | ||||||||||||||
| - quick | ||||||||||||||
| - standard | ||||||||||||||
| - deep | ||||||||||||||
|
|
||||||||||||||
| env: | ||||||||||||||
| DRY_RUN: true | ||||||||||||||
| PNPM: pnpm | ||||||||||||||
|
|
||||||||||||||
| permissions: | ||||||||||||||
| contents: read | ||||||||||||||
| pull-requests: write | ||||||||||||||
| issues: write | ||||||||||||||
|
|
||||||||||||||
| jobs: | ||||||||||||||
| orchestrate: | ||||||||||||||
| name: CyberAi Bot Orchestration | ||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||
|
|
||||||||||||||
| permissions: | ||||||||||||||
| contents: read | ||||||||||||||
| pull-requests: write | ||||||||||||||
| actions: read | ||||||||||||||
|
|
||||||||||||||
| steps: | ||||||||||||||
| - name: Checkout SmartContractAudit | ||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||
| with: | ||||||||||||||
| fetch-depth: 0 | ||||||||||||||
|
|
||||||||||||||
| - name: Setup Node.js | ||||||||||||||
| uses: actions/setup-node@v4 | ||||||||||||||
| with: | ||||||||||||||
| node-version: '20' | ||||||||||||||
|
|
||||||||||||||
| - name: Install pnpm | ||||||||||||||
| run: npm install -g pnpm | ||||||||||||||
|
|
||||||||||||||
| - name: Setup Environment | ||||||||||||||
| run: | | ||||||||||||||
| echo "Setting up CyberAi Bot environment..." | ||||||||||||||
|
|
||||||||||||||
| # Copy environment template | ||||||||||||||
| if [ -f .env.example ]; then | ||||||||||||||
| cp .env.example .env | ||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| # Configure dry-run mode | ||||||||||||||
| echo "DRY_RUN=true" >> .env | ||||||||||||||
| echo "PNPM=pnpm" >> .env | ||||||||||||||
| echo "LOG_LEVEL=INFO" >> .env | ||||||||||||||
|
|
||||||||||||||
| # Make scripts executable | ||||||||||||||
| chmod +x scripts/*.sh | ||||||||||||||
|
|
||||||||||||||
| # Create necessary directories | ||||||||||||||
| mkdir -p logs | ||||||||||||||
| mkdir -p reports | ||||||||||||||
| mkdir -p .quarantine | ||||||||||||||
|
|
||||||||||||||
| - name: Install Dependencies | ||||||||||||||
| if: hashFiles('package.json') != '' | ||||||||||||||
| run: | | ||||||||||||||
| if [ -f pnpm-lock.yaml ]; then | ||||||||||||||
| pnpm install --frozen-lockfile || pnpm install | ||||||||||||||
| else | ||||||||||||||
| pnpm install || true | ||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| - name: SmartBrain Health Check | ||||||||||||||
| id: health_check | ||||||||||||||
| run: | | ||||||||||||||
| echo "Running SmartBrain health check..." | ||||||||||||||
|
|
||||||||||||||
| # Run health check | ||||||||||||||
| ./scripts/master.sh health || echo "Health check completed with warnings" | ||||||||||||||
|
|
||||||||||||||
| # Check if SMARTBRAIN.log exists and has content | ||||||||||||||
| if [ -f SMARTBRAIN.log ]; then | ||||||||||||||
| echo "health_status=success" >> $GITHUB_OUTPUT | ||||||||||||||
| echo "Health check log:" | ||||||||||||||
| tail -20 SMARTBRAIN.log | ||||||||||||||
| else | ||||||||||||||
| echo "health_status=warning" >> $GITHUB_OUTPUT | ||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| - name: CyberAi Bot - Audit Orchestration | ||||||||||||||
| id: audit | ||||||||||||||
| if: github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | ||||||||||||||
| run: | | ||||||||||||||
| echo "Starting CyberAi Bot audit orchestration..." | ||||||||||||||
|
|
||||||||||||||
| # Determine audit mode | ||||||||||||||
| AUDIT_MODE="${{ github.event.inputs.mode || 'dry-run' }}" | ||||||||||||||
| AUDIT_DEPTH="${{ github.event.inputs.audit_depth || 'standard' }}" | ||||||||||||||
|
|
||||||||||||||
| echo "Audit mode: $AUDIT_MODE" | ||||||||||||||
| echo "Audit depth: $AUDIT_DEPTH" | ||||||||||||||
|
|
||||||||||||||
| # Run audit through SmartBrain orchestrator | ||||||||||||||
| if [ "$AUDIT_MODE" = "dry-run" ]; then | ||||||||||||||
| export DRY_RUN=true | ||||||||||||||
| else | ||||||||||||||
| export DRY_RUN=false | ||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| # Execute audit | ||||||||||||||
| ./scripts/master.sh audit || echo "Audit completed with findings" | ||||||||||||||
|
|
||||||||||||||
| # Store audit status | ||||||||||||||
| if [ -f AUDIT-REPORT.md ]; then | ||||||||||||||
| echo "audit_status=completed" >> $GITHUB_OUTPUT | ||||||||||||||
| else | ||||||||||||||
| echo "audit_status=no_report" >> $GITHUB_OUTPUT | ||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| - name: CyberAi Bot - Security Scan | ||||||||||||||
| id: security_scan | ||||||||||||||
| run: | | ||||||||||||||
| echo "Running CyberAi Bot security scan..." | ||||||||||||||
|
|
||||||||||||||
| # Run security scan | ||||||||||||||
| ./scripts/master.sh scan || echo "Security scan completed" | ||||||||||||||
|
|
||||||||||||||
| # Check quarantine | ||||||||||||||
| if [ -d .quarantine ] && [ "$(ls -A .quarantine)" ]; then | ||||||||||||||
| echo "scan_findings=true" >> $GITHUB_OUTPUT | ||||||||||||||
| echo "Security findings detected in .quarantine/" | ||||||||||||||
| else | ||||||||||||||
| echo "scan_findings=false" >> $GITHUB_OUTPUT | ||||||||||||||
| echo "No security issues detected" | ||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| - name: CyberAi Bot - Integrity Check | ||||||||||||||
| id: integrity | ||||||||||||||
| if: github.event_name == 'pull_request' || github.event_name == 'push' | ||||||||||||||
| run: | | ||||||||||||||
| echo "Running CyberAi Bot integrity check..." | ||||||||||||||
|
|
||||||||||||||
| # Run integrity check | ||||||||||||||
| ./scripts/master.sh integrity || echo "Integrity check completed" | ||||||||||||||
|
|
||||||||||||||
| echo "integrity_status=completed" >> $GITHUB_OUTPUT | ||||||||||||||
|
|
||||||||||||||
| - name: CyberAi Bot - Aggregate Results | ||||||||||||||
| id: aggregate | ||||||||||||||
| run: | | ||||||||||||||
| echo "Aggregating CyberAi Bot results..." | ||||||||||||||
|
|
||||||||||||||
| # Create comprehensive report | ||||||||||||||
| cat > reports/cyberai-summary.md <<EOF | ||||||||||||||
| # CyberAi Bot Execution Summary | ||||||||||||||
|
|
||||||||||||||
| **Run Date**: $(date -u +"%Y-%m-%d %H:%M:%S UTC") | ||||||||||||||
| **Trigger**: ${{ github.event_name }} | ||||||||||||||
| **Branch**: ${{ github.ref_name }} | ||||||||||||||
| **Commit**: ${{ github.sha }} | ||||||||||||||
|
|
||||||||||||||
| ## Results | ||||||||||||||
|
|
||||||||||||||
| ### Health Check | ||||||||||||||
| - Status: ${{ steps.health_check.outputs.health_status || 'not_run' }} | ||||||||||||||
|
|
||||||||||||||
| ### Audit | ||||||||||||||
| - Status: ${{ steps.audit.outputs.audit_status || 'not_run' }} | ||||||||||||||
| - Mode: ${{ github.event.inputs.mode || 'dry-run' }} | ||||||||||||||
|
|
||||||||||||||
| ### Security Scan | ||||||||||||||
| - Status: ${{ steps.security_scan.outputs.scan_findings == 'true' && 'findings_detected' || 'clean' }} | ||||||||||||||
|
|
||||||||||||||
| ### Integrity Check | ||||||||||||||
| - Status: ${{ steps.integrity.outputs.integrity_status || 'not_run' }} | ||||||||||||||
|
|
||||||||||||||
| ## Logs | ||||||||||||||
|
|
||||||||||||||
| EOF | ||||||||||||||
|
|
||||||||||||||
| # Append SmartBrain log if exists | ||||||||||||||
| if [ -f SMARTBRAIN.log ]; then | ||||||||||||||
| echo "### SmartBrain Log (Last 50 lines)" >> reports/cyberai-summary.md | ||||||||||||||
| echo '```' >> reports/cyberai-summary.md | ||||||||||||||
| tail -50 SMARTBRAIN.log >> reports/cyberai-summary.md | ||||||||||||||
| echo '```' >> reports/cyberai-summary.md | ||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| # Display summary | ||||||||||||||
| cat reports/cyberai-summary.md | ||||||||||||||
|
|
||||||||||||||
| - name: Upload Audit Report | ||||||||||||||
| if: steps.audit.outputs.audit_status == 'completed' | ||||||||||||||
| uses: actions/upload-artifact@v4 | ||||||||||||||
| with: | ||||||||||||||
| name: audit-report-${{ github.run_number }} | ||||||||||||||
| path: | | ||||||||||||||
| AUDIT-REPORT.md | ||||||||||||||
| SMARTBRAIN.log | ||||||||||||||
| retention-days: 30 | ||||||||||||||
|
|
||||||||||||||
| - name: Upload Security Findings | ||||||||||||||
| if: steps.security_scan.outputs.scan_findings == 'true' | ||||||||||||||
| uses: actions/upload-artifact@v4 | ||||||||||||||
| with: | ||||||||||||||
| name: security-findings-${{ github.run_number }} | ||||||||||||||
| path: .quarantine/ | ||||||||||||||
| retention-days: 90 | ||||||||||||||
|
|
||||||||||||||
| - name: Upload CyberAi Summary | ||||||||||||||
| uses: actions/upload-artifact@v4 | ||||||||||||||
| with: | ||||||||||||||
| name: cyberai-summary-${{ github.run_number }} | ||||||||||||||
| path: reports/cyberai-summary.md | ||||||||||||||
| retention-days: 30 | ||||||||||||||
|
|
||||||||||||||
| - name: Comment on PR | ||||||||||||||
| if: github.event_name == 'pull_request' | ||||||||||||||
| uses: actions/github-script@v7 | ||||||||||||||
| with: | ||||||||||||||
| script: | | ||||||||||||||
| const fs = require('fs'); | ||||||||||||||
|
|
||||||||||||||
| let body = '## 🤖 CyberAi Bot Report\n\n'; | ||||||||||||||
|
|
||||||||||||||
| // Add health check status | ||||||||||||||
| body += '### Health Check\n'; | ||||||||||||||
| body += `- Status: ${{ steps.health_check.outputs.health_status }}\n\n`; | ||||||||||||||
|
|
||||||||||||||
| // Add audit status | ||||||||||||||
| if ('${{ steps.audit.outputs.audit_status }}' !== 'not_run') { | ||||||||||||||
| body += '### Audit\n'; | ||||||||||||||
| body += `- Status: ${{ steps.audit.outputs.audit_status }}\n`; | ||||||||||||||
|
Comment on lines
+253
to
+255
|
||||||||||||||
| if ('${{ steps.audit.outputs.audit_status }}' !== 'not_run') { | |
| body += '### Audit\n'; | |
| body += `- Status: ${{ steps.audit.outputs.audit_status }}\n`; | |
| if ("${{ steps.audit.outputs.audit_status || 'not_run' }}" !== 'not_run') { | |
| body += '### Audit\n'; | |
| body += `- Status: ${{ steps.audit.outputs.audit_status || 'not_run' }}\n`; |
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 job-level
permissionsblock omitsissues: write, but the workflow later usesgithub.rest.issues.createComment(...)to comment on PRs. Because job-level permissions override the workflow-level permissions, this step is likely to fail with an authorization error. Addissues: writeto theorchestratejob permissions (or remove the job-level override so the workflow-levelissues: writeapplies).