|
| 1 | +name: Security |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + schedule: |
| 9 | + - cron: '0 3 * * *' |
| 10 | + release: |
| 11 | + types: [published] |
| 12 | + |
| 13 | +env: |
| 14 | + CARGO_TERM_COLOR: always |
| 15 | + RUST_BACKTRACE: 1 |
| 16 | + |
| 17 | +jobs: |
| 18 | + fast-security: |
| 19 | + name: Fast Security Checks |
| 20 | + runs-on: ubuntu-latest |
| 21 | + if: github.event_name == 'push' || github.event_name == 'pull_request' |
| 22 | + steps: |
| 23 | + - name: Checkout code |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Install Rust toolchain |
| 27 | + uses: dtolnay/rust-toolchain@stable |
| 28 | + with: |
| 29 | + toolchain: "1.85" |
| 30 | + components: clippy |
| 31 | + |
| 32 | + - name: Cache Rust dependencies |
| 33 | + uses: actions/cache@v4 |
| 34 | + with: |
| 35 | + path: | |
| 36 | + ~/.cargo/registry/index/ |
| 37 | + ~/.cargo/registry/cache/ |
| 38 | + ~/.cargo/git/db/ |
| 39 | + target/ |
| 40 | + key: ${{ runner.os }}-cargo-security-${{ hashFiles('**/Cargo.lock') }} |
| 41 | + restore-keys: | |
| 42 | + ${{ runner.os }}-cargo-security- |
| 43 | + ${{ runner.os }}-cargo- |
| 44 | +
|
| 45 | + - name: Install cargo-audit |
| 46 | + run: cargo install cargo-audit --locked |
| 47 | + |
| 48 | + - name: Install cargo-deny |
| 49 | + run: cargo install cargo-deny --locked |
| 50 | + |
| 51 | + - name: Run cargo audit (CVE scanning) |
| 52 | + run: cargo audit |
| 53 | + |
| 54 | + - name: Run cargo deny (license compliance + advisories) |
| 55 | + run: cargo deny check |
| 56 | + |
| 57 | + - name: Run clippy (strict linting) |
| 58 | + run: cargo clippy --all-features --all-targets -- -D warnings |
| 59 | + |
| 60 | + - name: Run tests |
| 61 | + run: cargo test --all-features |
| 62 | + |
| 63 | + quick-fuzz: |
| 64 | + name: Quick Fuzz (Corpus Only) |
| 65 | + runs-on: ubuntu-latest |
| 66 | + if: github.event_name == 'push' || github.event_name == 'pull_request' |
| 67 | + strategy: |
| 68 | + fail-fast: false |
| 69 | + matrix: |
| 70 | + target: |
| 71 | + - byte_storage_checksum_collision |
| 72 | + - byte_storage_compress |
| 73 | + - byte_storage_corrupted_envelope |
| 74 | + - byte_storage_decompress |
| 75 | + - byte_storage_empty_data |
| 76 | + - byte_storage_format_injection |
| 77 | + - byte_storage_integer_overflow |
| 78 | + - compression_bomb |
| 79 | + - encryption_aad_injection |
| 80 | + - encryption_key_derivation |
| 81 | + - encryption_large_payload |
| 82 | + - encryption_nonce_reuse |
| 83 | + - encryption_roundtrip |
| 84 | + - encryption_truncated_ciphertext |
| 85 | + - integration_layered_security |
| 86 | + - key_derivation |
| 87 | + steps: |
| 88 | + - name: Checkout code |
| 89 | + uses: actions/checkout@v4 |
| 90 | + |
| 91 | + - name: Install Rust toolchain |
| 92 | + uses: dtolnay/rust-toolchain@stable |
| 93 | + with: |
| 94 | + toolchain: "1.85" |
| 95 | + |
| 96 | + - name: Cache Rust dependencies |
| 97 | + uses: actions/cache@v4 |
| 98 | + with: |
| 99 | + path: | |
| 100 | + ~/.cargo/registry/index/ |
| 101 | + ~/.cargo/registry/cache/ |
| 102 | + ~/.cargo/git/db/ |
| 103 | + fuzz/target/ |
| 104 | + key: ${{ runner.os }}-cargo-fuzz-${{ hashFiles('**/Cargo.lock') }} |
| 105 | + restore-keys: | |
| 106 | + ${{ runner.os }}-cargo-fuzz- |
| 107 | + ${{ runner.os }}-cargo- |
| 108 | +
|
| 109 | + - name: Install cargo-fuzz |
| 110 | + run: cargo install cargo-fuzz --locked |
| 111 | + |
| 112 | + - name: Run quick fuzz (corpus only) |
| 113 | + run: | |
| 114 | + cd fuzz |
| 115 | + timeout 120 cargo fuzz run ${{ matrix.target }} -- -runs=0 -max_total_time=120 || true |
| 116 | +
|
| 117 | + deep-fuzz: |
| 118 | + name: Deep Fuzzing (8 hours) |
| 119 | + runs-on: ubuntu-latest |
| 120 | + if: github.event_name == 'schedule' |
| 121 | + strategy: |
| 122 | + fail-fast: false |
| 123 | + matrix: |
| 124 | + target: |
| 125 | + - byte_storage_checksum_collision |
| 126 | + - byte_storage_compress |
| 127 | + - byte_storage_corrupted_envelope |
| 128 | + - byte_storage_decompress |
| 129 | + - byte_storage_empty_data |
| 130 | + - byte_storage_format_injection |
| 131 | + - byte_storage_integer_overflow |
| 132 | + - compression_bomb |
| 133 | + - encryption_aad_injection |
| 134 | + - encryption_key_derivation |
| 135 | + - encryption_large_payload |
| 136 | + - encryption_nonce_reuse |
| 137 | + - encryption_roundtrip |
| 138 | + - encryption_truncated_ciphertext |
| 139 | + - integration_layered_security |
| 140 | + - key_derivation |
| 141 | + steps: |
| 142 | + - name: Checkout code |
| 143 | + uses: actions/checkout@v4 |
| 144 | + |
| 145 | + - name: Install Rust toolchain |
| 146 | + uses: dtolnay/rust-toolchain@stable |
| 147 | + with: |
| 148 | + toolchain: "1.85" |
| 149 | + |
| 150 | + - name: Cache Rust dependencies |
| 151 | + uses: actions/cache@v4 |
| 152 | + with: |
| 153 | + path: | |
| 154 | + ~/.cargo/registry/index/ |
| 155 | + ~/.cargo/registry/cache/ |
| 156 | + ~/.cargo/git/db/ |
| 157 | + fuzz/target/ |
| 158 | + key: ${{ runner.os }}-cargo-fuzz-${{ hashFiles('**/Cargo.lock') }} |
| 159 | + restore-keys: | |
| 160 | + ${{ runner.os }}-cargo-fuzz- |
| 161 | + ${{ runner.os }}-cargo- |
| 162 | +
|
| 163 | + - name: Install cargo-fuzz |
| 164 | + run: cargo install cargo-fuzz --locked |
| 165 | + |
| 166 | + - name: Run deep fuzz (30 minutes per target) |
| 167 | + run: | |
| 168 | + cd fuzz |
| 169 | + timeout 1800 cargo fuzz run ${{ matrix.target }} -- -max_total_time=1800 || true |
| 170 | +
|
| 171 | + - name: Upload crash artifacts |
| 172 | + if: always() |
| 173 | + uses: actions/upload-artifact@v4 |
| 174 | + with: |
| 175 | + name: fuzz-crashes-${{ matrix.target }} |
| 176 | + path: fuzz/artifacts/${{ matrix.target }}/ |
| 177 | + if-no-files-found: ignore |
| 178 | + |
| 179 | + kani: |
| 180 | + name: Kani Formal Verification |
| 181 | + runs-on: ubuntu-latest |
| 182 | + if: github.event_name == 'schedule' |
| 183 | + steps: |
| 184 | + - name: Checkout code |
| 185 | + uses: actions/checkout@v4 |
| 186 | + |
| 187 | + - name: Install Rust toolchain |
| 188 | + uses: dtolnay/rust-toolchain@stable |
| 189 | + with: |
| 190 | + toolchain: "1.85" |
| 191 | + |
| 192 | + - name: Cache Rust dependencies |
| 193 | + uses: actions/cache@v4 |
| 194 | + with: |
| 195 | + path: | |
| 196 | + ~/.cargo/registry/index/ |
| 197 | + ~/.cargo/registry/cache/ |
| 198 | + ~/.cargo/git/db/ |
| 199 | + target/ |
| 200 | + key: ${{ runner.os }}-cargo-kani-${{ hashFiles('**/Cargo.lock') }} |
| 201 | + restore-keys: | |
| 202 | + ${{ runner.os }}-cargo-kani- |
| 203 | + ${{ runner.os }}-cargo- |
| 204 | +
|
| 205 | + - name: Install Kani |
| 206 | + run: | |
| 207 | + cargo install --locked kani-verifier || echo "Kani install failed, skipping verification" |
| 208 | + cargo kani setup || echo "Kani setup failed, skipping verification" |
| 209 | +
|
| 210 | + - name: Run Kani verification |
| 211 | + run: cargo kani --all-features || echo "Kani verification failed or not supported" |
| 212 | + continue-on-error: true |
| 213 | + |
| 214 | + cargo-vet: |
| 215 | + name: Cargo Vet (Supply Chain) |
| 216 | + runs-on: ubuntu-latest |
| 217 | + if: github.event_name == 'schedule' |
| 218 | + steps: |
| 219 | + - name: Checkout code |
| 220 | + uses: actions/checkout@v4 |
| 221 | + |
| 222 | + - name: Install Rust toolchain |
| 223 | + uses: dtolnay/rust-toolchain@stable |
| 224 | + with: |
| 225 | + toolchain: "1.85" |
| 226 | + |
| 227 | + - name: Cache Rust dependencies |
| 228 | + uses: actions/cache@v4 |
| 229 | + with: |
| 230 | + path: | |
| 231 | + ~/.cargo/registry/index/ |
| 232 | + ~/.cargo/registry/cache/ |
| 233 | + ~/.cargo/git/db/ |
| 234 | + target/ |
| 235 | + key: ${{ runner.os }}-cargo-vet-${{ hashFiles('**/Cargo.lock') }} |
| 236 | + restore-keys: | |
| 237 | + ${{ runner.os }}-cargo-vet- |
| 238 | + ${{ runner.os }}-cargo- |
| 239 | +
|
| 240 | + - name: Install cargo-vet |
| 241 | + run: cargo install cargo-vet --locked |
| 242 | + |
| 243 | + - name: Run cargo vet |
| 244 | + run: cargo vet |
| 245 | + |
| 246 | + sbom: |
| 247 | + name: Generate SBOM |
| 248 | + runs-on: ubuntu-latest |
| 249 | + if: github.event_name == 'release' |
| 250 | + steps: |
| 251 | + - name: Checkout code |
| 252 | + uses: actions/checkout@v4 |
| 253 | + |
| 254 | + - name: Install Rust toolchain |
| 255 | + uses: dtolnay/rust-toolchain@stable |
| 256 | + with: |
| 257 | + toolchain: "1.85" |
| 258 | + |
| 259 | + - name: Cache Rust dependencies |
| 260 | + uses: actions/cache@v4 |
| 261 | + with: |
| 262 | + path: | |
| 263 | + ~/.cargo/registry/index/ |
| 264 | + ~/.cargo/registry/cache/ |
| 265 | + ~/.cargo/git/db/ |
| 266 | + target/ |
| 267 | + key: ${{ runner.os }}-cargo-sbom-${{ hashFiles('**/Cargo.lock') }} |
| 268 | + restore-keys: | |
| 269 | + ${{ runner.os }}-cargo-sbom- |
| 270 | + ${{ runner.os }}-cargo- |
| 271 | +
|
| 272 | + - name: Install cargo-sbom |
| 273 | + run: cargo install cargo-sbom --locked |
| 274 | + |
| 275 | + - name: Generate SBOM |
| 276 | + run: cargo sbom > cachekit-core-sbom.json |
| 277 | + |
| 278 | + - name: Upload SBOM as release asset |
| 279 | + uses: actions/upload-release-asset@v1 |
| 280 | + env: |
| 281 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 282 | + with: |
| 283 | + upload_url: ${{ github.event.release.upload_url }} |
| 284 | + asset_path: ./cachekit-core-sbom.json |
| 285 | + asset_name: cachekit-core-sbom.json |
| 286 | + asset_content_type: application/json |
0 commit comments