Skip to content

About

Jutsu code security: Gitleaks and OSV, run in your own GitHub Actions

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jutsu Security scan

A reusable GitHub Actions workflow that scans a repository's changes for committed secrets (Gitleaks 8.30.1) and for dependencies with known vulnerabilities (osv-scanner 2.6.0), and sends the results to Jutsu. It runs on your runner, and the findings are encrypted before they leave the scan job, so the run log holds only ciphertext.

With AI review on (the default), each secret finding's full value and up to 8 lines of source around it leave your runner. They go to Jutsu and to Jutsu's AI model provider, so Jutsu AI can judge whether each finding is a real credential or test data. Jutsu deletes them from its live database once they are judged, and within 7 days at the latest. To keep every value and every line of source on your runner, set ai_review: false (see AI review) or turn AI review off in Jutsu's code security settings.

A repository uses it through .github/workflows/jutsu-security.yml. You add that file yourself; the Jutsu console shows it for your repository and links to GitHub's editor with it filled in:

name: Jutsu Security
on:
  pull_request:
  push:
    branches: [main]
  workflow_dispatch:
permissions: {}
jobs:
  jutsu:
    permissions:
      contents: read     # the scan reads the repository on the runner
      id-token: write    # the report proves which workflow produced it
    uses: jutsuai/code-security/.github/workflows/scan.yml@<40-character commit SHA>
    with:
      encrypt_to: "<44-character public key>"   # Jutsu's public key: findings are encrypted to it before they leave the scan job
      # ai_review: false   # uncomment to send findings only: no secret values or source lines for Jutsu AI to review

It passes no secrets. encrypt_to is a PUBLIC key: anyone may read it, and only Jutsu holds the private half. Use the file from the Jutsu console unchanged: Jutsu accepts reports only from the releases it lists, and can only open findings encrypted to its own key.

Jutsu's GitHub App has no write access to your code. It cannot add or change this file; it reads the repository's metadata and posts the "Jutsu Security" check.

What it does

The workflow has two jobs.

scan has contents: read and no identity token. It:

  1. fetches the commits under review with the run's own read-only token, without checking out a working tree: <merge base>..<head> for a pull request, <before>..<after> for a push. A new branch, a manual run and a push that changes jutsu-security.yml also scan the current tree;
  2. runs Gitleaks over those commits (merge commits included) with Jutsu's configuration. It reports provider keys (AWS, Stripe, GitHub, OpenAI and the rest of Gitleaks' provider rules), private keys and Jutsu's own keys. Shape-only rules (generic-api-key, jwt, curl-auth-header, curl-auth-user, and Sourcegraph's bare 40-hex form, which matches commit SHAs) are off. A repository's own .gitleaks.toml, .gitleaksignore and gitleaks:allow comments have no effect, so a change cannot switch off its own scan;
  3. writes each lockfile (from the head and from the base) to a scratch directory and runs osv-scanner on it with an empty configuration and no dependency resolution. A vulnerability is introduced when the head has it and the base does not;
  4. replaces each secret value with its SHA-256 digest and discards the tools' own output, so a secret a tool prints never reaches the run's log. With AI review on, it keeps each finding's value and the lines around it in memory for the encrypted result (see AI review); with it off, the value is dropped;
  5. compresses the result and encrypts it to the encrypt_to key, bound to this repository and run, and passes that to the report job. The job output, which GitHub shows in the run log, is ciphertext.

It never installs, builds or runs anything from the repository. The two scanners are downloaded from their GitHub releases and checked against pinned sha256 sums (tools.json) before they run.

report has id-token: write and no access to the repository. It asks GitHub for an identity token for Jutsu's API, adds the run's own facts (event, pull request number, head and base, run id and attempt), and forwards the encrypted result without being able to read it, retrying for up to ten minutes. If the scan job failed, timed out or was cancelled, it reports that instead.

Limits: at most 250 commits, 200 lockfiles, 20 MB per lockfile and 500 findings per tool. A change over a limit is reported as incompletely scanned, never as clean. Past 500, provider and Jutsu keys are kept before private keys, and vulnerabilities with the highest severity are kept first.

AI review

On by default. For each secret finding it sends (at most 500), the encrypted result also carries:

  • value: the secret exactly as Gitleaks found it, unmasked, cut at 1,024 bytes;
  • lines: up to 8 lines of the file around it (two before and two after the finding's own lines), each cut at 200 bytes around the secret, with their line numbers. Files over 1 MiB, binary files, and anything past 64 MiB of reading in one run send the value without lines.

For each vulnerable dependency it carries usage, read from the lockfile (bun.lock, package-lock.json v2/v3, pnpm-lock.yaml): whether the package is a direct or transitive dependency, whether it is reached through production, development or optional dependencies, and up to three dependency chains such as apps/web › vite@4.5.3 › esbuild@0.18.20.

Where it goes: to Jutsu, inside the same encrypted result as the findings, and from Jutsu to its AI model provider, which judges each finding. Jutsu never shows a value or a line in its console.

How long it is kept: Jutsu deletes values, lines and usage from its live database once the finding is judged, and within 7 days at the latest. Jutsu's database backups keep data for their retention window, and the model provider keeps requests under its API data policy.

How to turn it off, either way:

  • in .github/workflows/jutsu-security.yml, under with:, add ai_review: false;
  • or turn off AI review in Jutsu's code security settings. The console then gives you the file with ai_review: false in it, and until you update the file Jutsu drops any values it still receives before storing anything.

With it off, the result carries identifiers only, as listed below without evidence and usage: no secret value and no line of source leaves your runner.

What it sends

This, and nothing else. The parts marked AI review are sent only with ai_review on:

identity (from the report job's own context), by event:
  pull_request:      prNumber, ref = refs/pull/<prNumber>/merge, sha (the merge commit GitHub ran on),
                     headSha, baseRef, baseSha, runId, runAttempt
  push:              ref = refs/heads/<branch>, sha = after, before, after, headSha = after, runId, runAttempt
  workflow_dispatch: ref = refs/heads/<branch>, sha, headSha = sha, runId, runAttempt
scan (the scan job's output: encrypted on your runner, opened only by Jutsu's API):
  scanResult: success | failure | cancelled | timed_out
  secrets: { coverage: complete|incomplete_input|failed, reason, tool: {name, version},
             findings: [{ ruleId, path, startLine, endLine, commitSha, valueDigest, inHeadTree,
                          evidence (AI review): { value, valueTruncated,
                                                  lines: [{ n, text }] | omitted } }] }
  vulnerabilities: {
             coverage: { head: complete|incomplete_input|failed, base: complete|incomplete|none },
             reason: { head, base }, manifests: [{ side, path, status }], tool, queriedAt,
             findings: [{ advisoryIds[], ecosystem, package, version, manifestPath, introduced,
                          usage (AI review): { relation, scopes[], via[] } }] }
  commits: [sha]  (what the range scan covered, at most 250)
  inventory (default-branch runs): [{ ecosystem, package, version, manifestPath }]
  treeScanned: boolean

In words: file paths, line numbers, commit SHAs, package names and versions, advisory ids, rule ids, and a SHA-256 digest of each secret. Jutsu re-keys each digest with a server-side key before storing it. A digest of a short, guessable secret can be guessed; that is what lets Jutsu recognise the same secret twice. With AI review on, also each secret's value, the lines around it, and each vulnerable dependency's usage, as described under AI review.

How it is encrypted: a fresh X25519 key pair per run, HKDF-SHA256, AES-256-GCM, with the repository id and run id as associated data, so a result copied from another run's log does not open. The code is dist/scan.js in this repository; the scan job's last log line names the key id it used.

Package names and versions are also sent to OSV by osv-scanner, from your runner.

Pull requests from forks

A run for a pull request from a fork gets no identity token from GitHub, so it cannot send a report, and its report job fails with that reason. Jutsu does not scan pull requests from forks.

About

Jutsu code security: Gitleaks and OSV, run in your own GitHub Actions

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors