|
| 1 | +name: dependency-audit |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Run on the first day of every month at 9:00 AM UTC |
| 6 | + - cron: '0 9 1 * *' |
| 7 | + workflow_dispatch: # Allow manual triggering |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + issues: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + audit-dart: |
| 15 | + name: Audit Dart Package Dependencies |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - name: Checkout repository |
| 19 | + uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Setup Dart |
| 22 | + uses: dart-lang/setup-dart@v1 |
| 23 | + with: |
| 24 | + sdk: stable |
| 25 | + |
| 26 | + - name: Get dependencies |
| 27 | + working-directory: packages/dart |
| 28 | + run: dart pub get |
| 29 | + |
| 30 | + - name: Check for outdated dependencies |
| 31 | + id: outdated |
| 32 | + working-directory: packages/dart |
| 33 | + run: | |
| 34 | + echo "## Dart Package - Outdated Dependencies" >> $GITHUB_STEP_SUMMARY |
| 35 | + dart pub outdated --mode=outdated || true |
| 36 | + dart pub outdated --mode=outdated >> $GITHUB_STEP_SUMMARY || true |
| 37 | +
|
| 38 | + - name: Security audit |
| 39 | + id: audit |
| 40 | + working-directory: packages/dart |
| 41 | + run: | |
| 42 | + echo "## Dart Package - Security Audit" >> $GITHUB_STEP_SUMMARY |
| 43 | + dart pub audit || true |
| 44 | + dart pub audit >> $GITHUB_STEP_SUMMARY || true |
| 45 | +
|
| 46 | + audit-flutter: |
| 47 | + name: Audit Flutter Package Dependencies |
| 48 | + runs-on: ubuntu-latest |
| 49 | + steps: |
| 50 | + - name: Checkout repository |
| 51 | + uses: actions/checkout@v4 |
| 52 | + |
| 53 | + - name: Setup Flutter |
| 54 | + uses: subosito/flutter-action@v2 |
| 55 | + with: |
| 56 | + channel: stable |
| 57 | + |
| 58 | + - name: Get dependencies |
| 59 | + working-directory: packages/flutter |
| 60 | + run: flutter pub get |
| 61 | + |
| 62 | + - name: Check for outdated dependencies |
| 63 | + id: outdated |
| 64 | + working-directory: packages/flutter |
| 65 | + run: | |
| 66 | + echo "## Flutter Package - Outdated Dependencies" >> $GITHUB_STEP_SUMMARY |
| 67 | + flutter pub outdated --mode=outdated || true |
| 68 | + flutter pub outdated --mode=outdated >> $GITHUB_STEP_SUMMARY || true |
| 69 | +
|
| 70 | + - name: Security audit |
| 71 | + id: audit |
| 72 | + working-directory: packages/flutter |
| 73 | + run: | |
| 74 | + echo "## Flutter Package - Security Audit" >> $GITHUB_STEP_SUMMARY |
| 75 | + dart pub audit || true |
| 76 | + dart pub audit >> $GITHUB_STEP_SUMMARY || true |
| 77 | +
|
| 78 | + create-issue: |
| 79 | + name: Create Issue if Security Vulnerabilities Found |
| 80 | + needs: [audit-dart, audit-flutter] |
| 81 | + runs-on: ubuntu-latest |
| 82 | + if: failure() |
| 83 | + steps: |
| 84 | + - name: Create issue for security vulnerabilities |
| 85 | + uses: actions/github-script@v7 |
| 86 | + with: |
| 87 | + script: | |
| 88 | + const title = '[Security] Dependency vulnerabilities detected'; |
| 89 | + const body = `## Security Vulnerabilities Detected |
| 90 | +
|
| 91 | + The monthly dependency audit has detected security vulnerabilities in our dependencies. |
| 92 | +
|
| 93 | + ### Action Required |
| 94 | + 1. Review the [workflow run](${context.payload.repository.html_url}/actions/runs/${context.runId}) |
| 95 | + 2. Update affected dependencies |
| 96 | + 3. Test thoroughly |
| 97 | + 4. Create a PR with security fixes |
| 98 | +
|
| 99 | + ### Resources |
| 100 | + - [VERSIONING_POLICY.md](${context.payload.repository.html_url}/blob/master/VERSIONING_POLICY.md) |
| 101 | + - [Dart Security Best Practices](https://dart.dev/guides/libraries/secure) |
| 102 | +
|
| 103 | + --- |
| 104 | + **Auto-generated by dependency-audit workflow** |
| 105 | + `; |
| 106 | +
|
| 107 | + // Check if similar issue exists |
| 108 | + const issues = await github.rest.issues.listForRepo({ |
| 109 | + owner: context.repo.owner, |
| 110 | + repo: context.repo.repo, |
| 111 | + state: 'open', |
| 112 | + labels: 'security,dependencies' |
| 113 | + }); |
| 114 | +
|
| 115 | + const existingIssue = issues.data.find(issue => |
| 116 | + issue.title.includes('[Security] Dependency vulnerabilities') |
| 117 | + ); |
| 118 | +
|
| 119 | + if (!existingIssue) { |
| 120 | + await github.rest.issues.create({ |
| 121 | + owner: context.repo.owner, |
| 122 | + repo: context.repo.repo, |
| 123 | + title: title, |
| 124 | + body: body, |
| 125 | + labels: ['security', 'dependencies', 'high-priority'] |
| 126 | + }); |
| 127 | + } else { |
| 128 | + await github.rest.issues.createComment({ |
| 129 | + owner: context.repo.owner, |
| 130 | + repo: context.repo.repo, |
| 131 | + issue_number: existingIssue.number, |
| 132 | + body: `New vulnerabilities detected in [workflow run](${context.payload.repository.html_url}/actions/runs/${context.runId})` |
| 133 | + }); |
| 134 | + } |
0 commit comments