Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 137 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# Pull Request

## πŸ“‹ Description

<!-- Provide a clear and concise description of your changes -->

## 🎯 Type of Change

<!-- Check the relevant option(s) -->

- [ ] πŸ› Bug fix (non-breaking change which fixes an issue)
- [ ] ✨ New feature (non-breaking change which adds functionality)
- [ ] πŸ’₯ Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] πŸ“ Documentation update
- [ ] πŸ”’ Security fix
- [ ] ⚑ Performance improvement
- [ ] 🎨 Code style update (formatting, naming)
- [ ] ♻️ Code refactoring
- [ ] πŸ”§ Configuration change

## πŸ€– Bot Metadata

<!-- For automated PRs, fill this section -->

```yaml
bot_generated: false # Set to true if automated
bot_name: GitAntivirus
scan_date: YYYY-MM-DD
dry_run: true
confidence_score: N/A
```

## βœ… Safety Checklist

<!-- Ensure all items are checked before requesting review -->

- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published
- [ ] I have checked my code for security vulnerabilities
- [ ] No sensitive information (keys, tokens, passwords) is included
- [ ] I have updated the changelog (if applicable)

## πŸ” Testing

<!-- Describe the tests you ran and how to reproduce them -->

### Test Configuration

- **OS:** (e.g., Ubuntu 22.04, macOS 13)
- **Node Version:** (e.g., 20.x)
- **Package Manager:** (e.g., pnpm 8.x)

### Test Steps

1.
2.
3.

## πŸ“Š Audit Artifacts

<!-- Attach scan results, reports, or evidence -->

<details>
<summary>πŸ” Security Scan Results</summary>

```
[Paste security scan output here]
```

</details>

<details>
<summary>πŸ“¦ Dependency Audit</summary>

```
[Paste dependency audit output here]
```

</details>

<details>
<summary>πŸ§ͺ Test Results</summary>

```
[Paste test results here]
```

</details>

## πŸ“Έ Screenshots / Recordings

<!-- If applicable, add screenshots or recordings to help explain your changes -->

## πŸ”— Related Issues

<!-- Link related issues using #issue_number -->

Closes #
Relates to #

## πŸ“š Additional Context

<!-- Add any other context about the PR here -->

## πŸ”’ Security Notes

<!-- Important: Address security considerations -->

- **Secrets:** No secrets or credentials are included in this PR
- **Dependencies:** All new dependencies are from trusted sources
- **Permissions:** This PR requires the following permissions:
- **Impact:** Security impact assessment: [None/Low/Medium/High]

## πŸ“ Reviewer Notes

<!-- Specific instructions or areas for reviewers to focus on -->

---

## πŸ“‹ Post-Merge Checklist

<!-- Items to complete after merge -->

- [ ] Update production environment
- [ ] Notify stakeholders
- [ ] Update documentation site
- [ ] Monitor for issues
- [ ] Close related issues

---

*πŸ€– GitAntivirus PR Template v1.0.0*
243 changes: 243 additions & 0 deletions .github/workflows/gitantivirus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
name: GitAntivirus - Smart Contract Security Scanner

on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- main
- develop
schedule:
# Run daily at 2 AM UTC
- cron: '0 2 * * *'
workflow_dispatch:
inputs:
dry_run:
description: 'Run in dry-run mode'
required: false
default: 'true'
bot_pings:
description: 'Enable bot pings'
required: false
default: 'false'

permissions:
contents: write
pull-requests: write
issues: write

env:
DRY_RUN: ${{ github.event.inputs.dry_run || 'true' }}
BOT_PINGS_ENABLED: ${{ github.event.inputs.bot_pings || 'false' }}
ALLOWLIST_ORGS: ''
NODE_VERSION: '20'

jobs:
gitantivirus-scan:
name: πŸ›‘οΈ GitAntivirus Security Scan
runs-on: ubuntu-latest

steps:
- name: πŸ“₯ Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: πŸ”§ Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

- name: πŸ“¦ Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false

- name: πŸ” Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- name: πŸ’Ύ Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: πŸ“š Install dependencies
run: |
if [ -f "package.json" ]; then
pnpm install --frozen-lockfile || pnpm install || npm install
else
echo "No package.json found, skipping dependency installation"
fi

- name: πŸ” Make scripts executable
run: |
chmod +x scripts/*.sh || true
chmod +x node/bot/*.js || true

- name: πŸ”§ SMSDAO Repair (Dry-Run)
if: env.DRY_RUN == 'true'
run: |
echo "πŸ§ͺ Running SMSDAO repair in dry-run mode..."
if [ -f "scripts/master.sh" ]; then
./scripts/master.sh health --dry-run
fi

- name: 🧠 SmartBrain Orchestrator - Scan
run: |
echo "πŸ” Running SmartBrain scan..."
if [ -f "scripts/master.sh" ]; then
./scripts/master.sh scan --verbose
else
echo "⚠️ SmartBrain orchestrator not found"
fi

- name: πŸ”’ SmartBrain Orchestrator - Audit
run: |
echo "πŸ”’ Running SmartBrain audit..."
if [ -f "scripts/master.sh" ]; then
./scripts/master.sh audit --verbose
else
echo "⚠️ SmartBrain orchestrator not found"
fi

- name: πŸ’Š SmartBrain Orchestrator - Health Check
run: |
echo "πŸ’Š Running SmartBrain health check..."
if [ -f "scripts/master.sh" ]; then
./scripts/master.sh health --verbose
else
echo "⚠️ SmartBrain orchestrator not found"
fi

- name: πŸ“Š Generate Report
run: |
echo "πŸ“Š Generating comprehensive report..."
mkdir -p reports
if [ -f "scripts/master.sh" ]; then
./scripts/master.sh report --verbose > reports/analysis-report.txt
fi
echo "Report generated at: reports/analysis-report.txt"

- name: πŸ“€ Upload Audit Artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: gitantivirus-reports
path: |
reports/
/tmp/audit-report.json
retention-days: 30

- name: 🏷️ Add Labels to PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const labels = ['security-scan', 'gitantivirus'];
try {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: labels
});
console.log('βœ… Labels added successfully');
} catch (error) {
console.log('⚠️ Could not add labels:', error.message);
}

- name: πŸ’¬ Sticky PR Comment
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const botPingsEnabled = process.env.BOT_PINGS_ENABLED === 'true';
const repoOwner = context.repo.owner;
const dryRun = process.env.DRY_RUN === 'true';

// Construct comment body
let commentBody = `## πŸ›‘οΈ GitAntivirus Security Scan Report\n\n`;
commentBody += `**Status:** ${dryRun ? 'πŸ§ͺ Dry-Run Mode' : 'βœ… Active'}\n`;
commentBody += `**Scan Time:** ${new Date().toISOString()}\n\n`;

// Add report content if available
try {
if (fs.existsSync('reports/analysis-report.txt')) {
const report = fs.readFileSync('reports/analysis-report.txt', 'utf8');
commentBody += `### πŸ“Š Analysis Results\n\n\`\`\`\n${report.slice(0, 2000)}\n\`\`\`\n\n`;
}
} catch (error) {
console.log('Could not read report file:', error.message);
}

commentBody += `### πŸ” Security Checks\n`;
commentBody += `- βœ… Repository scanned for vulnerabilities\n`;
commentBody += `- βœ… Dependencies audited\n`;
commentBody += `- βœ… Code quality checked\n`;
commentBody += `- βœ… Health monitoring complete\n\n`;

// Conditionally add pings only for SolanaRemix org when enabled
if (botPingsEnabled && repoOwner === 'SolanaRemix') {
commentBody += `### πŸ“’ Notifications\n`;
commentBody += `cc: @SolanaRemix @smsdao @SmartBrain\n\n`;
}

commentBody += `---\n`;
commentBody += `*πŸ€– Automated by GitAntivirus | Powered by SmartBrain*\n`;

// Find existing comment
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});

const existingComment = comments.find(comment =>
comment.user.type === 'Bot' && comment.body.includes('GitAntivirus Security Scan Report')
);

try {
if (existingComment) {
// Update existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body: commentBody
});
console.log('βœ… Updated existing comment');
} else {
// Create new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: commentBody
});
console.log('βœ… Created new comment');
}
} catch (error) {
console.log('⚠️ Could not post comment:', error.message);
}

- name: πŸ“‹ Add to Project
if: github.event_name == 'pull_request' && secrets.PROJECT_URL
uses: actions/github-script@v7
continue-on-error: true
with:
script: |
const projectUrl = '${{ secrets.PROJECT_URL }}';
if (!projectUrl) {
console.log('⚠️ PROJECT_URL secret not configured');
return;
}
console.log('πŸ“‹ Would add to project:', projectUrl);
// Project addition logic would go here if PROJECT_URL is configured
Loading