62 lines
2.2 KiB
Markdown
62 lines
2.2 KiB
Markdown
# sast-scan
|
|
|
|
> **UNVERIFIED SCAFFOLD** — run `dagger develop` + `dagger functions` + test
|
|
> against a matching Dagger engine (engineVersion `v0.15.0`) before use. The
|
|
> Go in `main.go` has NOT been compiled or validated by Dagger codegen in
|
|
> this environment (`dagger develop` is unavailable, and the `dag` global
|
|
> plus the `*Directory` / `*Container` / `*File` types are generated). Do not
|
|
> assume it works as-is.
|
|
|
|
IntegraCI SAST (Static Application Security Testing) Dagger module. Runs
|
|
[Semgrep](https://semgrep.dev/) over a source directory, emits a SARIF
|
|
report, counts findings, and optionally POSTs the result to the IntegraCI
|
|
API.
|
|
|
|
It mirrors the structure and idioms of the sibling `security-scan` module.
|
|
|
|
## Functions
|
|
|
|
### `scan`
|
|
|
|
Runs Semgrep static analysis and returns a `ScanResult`.
|
|
|
|
| Param | Required | Default | Description |
|
|
| ------------ | -------- | ----------- | ------------------------------------------------ |
|
|
| `source` | yes | — | Source directory to scan |
|
|
| `tool` | no | `semgrep` | SAST tool to run; `none` skips scanning |
|
|
| `api-url` | no | — | IntegraCI API URL for posting results |
|
|
| `token` | no | — | JWT token for API authentication |
|
|
| `service-id` | no | — | Service ID to link scan results |
|
|
|
|
When `tool=none`, the scan is skipped and a result with `skipped=true` is
|
|
returned. Results are POSTed to the API only when both `api-url` and
|
|
`token` are set.
|
|
|
|
## Usage
|
|
|
|
> These commands are illustrative and have NOT been run here. Verify against
|
|
> a live Dagger engine first.
|
|
|
|
```sh
|
|
# Scan and post results to the IntegraCI API
|
|
dagger call scan \
|
|
--source . \
|
|
--api-url http://localhost:8000 \
|
|
--token "$TOKEN" \
|
|
--service-id "$SVC_ID"
|
|
|
|
# Scan only (no API post)
|
|
dagger call scan --source .
|
|
|
|
# Skip scanning
|
|
dagger call scan --source . --tool none
|
|
```
|
|
|
|
## Verifying the scaffold
|
|
|
|
```sh
|
|
dagger develop # generate the SDK + codegen
|
|
dagger functions # confirm the 'scan' function is exposed
|
|
gofmt -l main.go # confirm formatting (should print nothing)
|
|
```
|