You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# PR scan runs only when the PR diff touches supported file extensions (see paths below).
13
13
# workflow_dispatch and issue_comment have no path filter.
@@ -103,10 +103,17 @@ jobs:
103
103
- name: Prepare feedback DB directory
104
104
run: mkdir -p .ai-sast-db
105
105
106
+
- name: Require AI_SAST_REPO (use your fork)
107
+
run: |
108
+
if [ -z "${{ vars.AI_SAST_REPO }}" ]; then
109
+
echo "::error::Fork this repository (https://github.com/rivian/ai-sast), then set the repository variable AI_SAST_REPO to your fork (e.g. your-username/ai-sast). Settings → Secrets and variables → Actions → Variables."
echo "::error::Fork this repository (https://github.com/rivian/ai-sast), then set the repository variable AI_SAST_REPO to your fork (e.g. your-username/ai-sast). Settings → Secrets and variables → Actions → Variables."
The workflow checks out **`rivian/ai-sast`** at runtime. One file runs **PR scan** (on pull requests when base branch is `main`), **full scan** (manual "Run workflow"), and **feedback collection** (when someone edits a PR comment and checks a true/false positive box).
42
+
The workflow checks out **your fork** at runtime. One file runs **PR scan** (on pull requests when base branch is `main`), **full scan** (manual "Run workflow"), and **feedback collection** (when someone edits a PR comment and checks a true/false positive box).
38
43
39
-
**Optional:** Set variable `AI_SAST_REPO` (e.g. for a fork); `AI_SAST_BASE_BRANCH` (default `main`); `runs-on: self-hosted` in the workflow for your own runners.
44
+
**Optional:** Set `AI_SAST_BASE_BRANCH` (default `main`); `AI_SAST_REF` (default `main`); `runs-on: self-hosted` in the workflow for your own runners.
@@ -98,7 +103,7 @@ All configuration is driven by environment variables. The table below lists supp
98
103
| Variable | Description | Default |
99
104
|----------|-------------|---------|
100
105
|**Workflow & scan behavior**|||
101
-
|`AI_SAST_REPO`|GitHub repo to checkout (e.g. `org/ai-sast` or a fork). |`rivian/ai-sast` (in workflow)|
106
+
|`AI_SAST_REPO`|Your fork of this repo (e.g. `your-username/ai-sast`). **Required**—fork first, then set this variable. | —|
102
107
|`AI_SAST_BASE_BRANCH`| Branch that triggers PR scan; PRs targeting this branch are scanned. |`main`|
103
108
|`AI_SAST_SEVERITY`| Comma-separated severities to include in PR comments (e.g. `critical,high,medium`). The validator runs only on findings in these severities. |`critical,high`|
104
109
|`AI_SAST_UPDATE_SAME_PR_COMMENT`| When `true`, each PR scan run updates the same PR comment with the latest results instead of posting a new comment (reduces noise on multi-commit PRs). When `false` or unset, a new comment is posted every time (default). |`false`|
@@ -158,7 +163,7 @@ All configuration is driven by environment variables. The table below lists supp
158
163
-**Auth errors:** Service account needs "Vertex AI User" role; `GOOGLE_CREDENTIALS` must be the full JSON key.
159
164
-**No PR comment:** Ensure the PR targets the branch set by `AI_SAST_BASE_BRANCH` (default `main`).
160
165
-**Feedback not triggering:** The feedback job runs from your **default branch** (e.g. `main`). Make sure `ai-sast.yml` is merged to that branch—if it only exists on a feature branch, checking boxes in the PR comment won’t trigger the workflow.
161
-
-**Using a fork:**Set repository variable `AI_SAST_REPO` to your `org/ai-sast`.
166
+
-**Setup:**Fork this repo, then set repository variable `AI_SAST_REPO` to your fork (e.g. `your-username/ai-sast`).
Run AI-SAST (PR scan + full scan) **in your repo on your runners**. The workflow checks out the ai-sast scanner at runtime—no submodule or manual copy. Your code never runs on ai-sast infrastructure.
3
+
Run AI-SAST (PR scan + full scan) **in your repo on your runners**. The workflow checks out your fork of the ai-sast scanner at runtime—no submodule or manual copy. Your code never runs on ai-sast infrastructure.
4
4
5
-
## Required (2 steps)
5
+
## Required (4 steps)
6
6
7
-
### 1. Copy the workflow file
7
+
### 1. Fork this repository
8
+
9
+
Fork [rivian/ai-sast](https://github.com/rivian/ai-sast) so the workflow uses your fork. This also helps the project’s visibility (fork count) and lets you customize the scanner.
10
+
11
+
### 2. Copy the workflow file
8
12
9
13
-**From this repo:**[`.github/workflows/ai-sast.yml`](../.github/workflows/ai-sast.yml)
10
-
-**Save as:**`.github/workflows/ai-sast.yml` in **your**repository.
14
+
-**Save as:**`.github/workflows/ai-sast.yml` in the **repository you want to scan**(not necessarily the fork).
11
15
12
16
This single file runs PR scan, full scan, and feedback collection (when developers check boxes in PR comments). Feedback is stored in a database and included in the Vertex AI prompt on future scans to improve accuracy.
13
17
14
-
### 2. Add Google secrets
18
+
### 3. Set the AI_SAST_REPO variable
19
+
20
+
In the repository you want to scan: **Settings → Secrets and variables → Actions → Variables**
21
+
22
+
| Variable | Value |
23
+
|----------|--------|
24
+
|`AI_SAST_REPO`| Your fork (e.g. `your-username/ai-sast`) |
25
+
26
+
The workflow will checkout this repo at runtime. If you skip this, the workflow will fail with instructions to fork and set the variable.
27
+
28
+
### 4. Add Google secrets
15
29
16
-
In your repository: **Settings → Secrets and variables → Actions → Secrets**
30
+
In the same repository: **Settings → Secrets and variables → Actions → Secrets**
17
31
18
32
| Secret | Description |
19
33
|--------|-------------|
20
34
|`GOOGLE_CLOUD_PROJECT`| Your GCP project ID |
21
35
|`GOOGLE_CREDENTIALS`| Service account JSON (full contents of the key file) |
22
36
23
-
The workflow checks out **`rivian/ai-sast`** by default. That’s it—PR scan runs on pull requests (when base branch matches), full scan (manual "Run workflow"), and feedback collection (when a PR comment with the AI-SAST scan is edited and checkboxes are used).
37
+
That’s it—PR scan runs on pull requests (when base branch matches), full scan (manual "Run workflow"), and feedback collection (when a PR comment with the AI-SAST scan is edited and checkboxes are used).
24
38
25
39
## Optional
26
40
27
41
-**LLM provider:** Default is **Vertex AI** (Gemini). To use **AWS Bedrock (Claude)** set variable **`AI_SAST_LLM`** = `bedrock`, and set **`AWS_REGION`** (e.g. `us-east-1`), **`BEDROCK_MODEL_ID`**. Add AWS credentials as secrets (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`) or use an IAM role on the runner. For local **Ollama**, set **`AI_SAST_LLM`** = `ollama`.
28
-
-**Using a fork:** Set repository variable **`AI_SAST_REPO`** (e.g. `your-org/ai-sast`) to checkout your fork instead of `rivian/ai-sast`.
29
42
-**Default branch for PR scan:** Add variable **`AI_SAST_BASE_BRANCH`** (e.g. `main`, `master`, `develop`). Default is `main` if unset.
30
43
-**Scanner ref:** Add variable **`AI_SAST_REF`** (e.g. `main`, `v1.0`) to pin the ai-sast version. Default is `main`.
31
44
-**Update same PR comment:** Set **`AI_SAST_UPDATE_SAME_PR_COMMENT`** = `true` to update the existing AI-SAST comment on each scan run instead of posting a new one (reduces noise when multiple commits trigger multiple scans). Default is `false`.
@@ -38,7 +51,7 @@ The workflow checks out **`rivian/ai-sast`** by default. That’s it—PR scan r
38
51
39
52
## Troubleshooting
40
53
41
-
-**“repository not found” or checkout fails:**You may be using a fork; set `AI_SAST_REPO` to your `org/ai-sast`.
54
+
-**“repository not found” or checkout fails:**Ensure `AI_SAST_REPO`is set to your fork (e.g. `your-username/ai-sast`). You must fork the repo first.
42
55
-**No PR comment:** Check that the PR targets the branch set by `AI_SAST_BASE_BRANCH` (or `main`). Check the “Run AI-SAST PR Scan” step logs.
43
56
-**Feedback not triggering when you check boxes:** The `issue_comment` event runs the workflow from your **default branch** (e.g. `main`). Ensure `ai-sast.yml` is committed and merged to that branch—if the file exists only on a feature branch, feedback collection will not run.
44
57
-**Auth errors:** Ensure the service account has the “Vertex AI User” role and that `GOOGLE_CREDENTIALS` is the **full** JSON key (not a path).
0 commit comments