GitHub
11/13/2026, 5:00 PMPOST /api/v1/santa/{env}/rules/import takes a JSON list of rules and returns the report (new, duplicate, conflicts, invalid, applied). With ?dry_run=true nothing is stored. A blocked import returns 200 with applied: false.
• Export format: the eight portable rule fields, sorted by type, identifier and scope so the file diffs cleanly. The import ignores extra fields, so the output of GET /api/v1/santa/{env}/rules can be imported as is.
• UI: the Rules tab gets Export (downloads santa-rules-<env>.json) and Import. Import runs the dry run first and shows the report; the confirm button is disabled when a rule is conflicting or invalid.
• CLI: osctrl-cli santa rules-export -e ENV [-f FILE] and osctrl-cli santa rules-import -e ENV -f FILE [--dry-run], in API and DB mode. rules-import exits non-zero when the import is blocked, dry run included, so it can gate a review pipeline.
• Docs: pkg/santa/README.md has a new "Bulk import and export" section, and osctrl-api.yaml is regenerated.
Security and operational impact
• The import route goes through santaEnvironment, so it requires environment admin.
• environment_id and created_by come from the URL and the session; id, environment_id and created_by in the body are ignored.
• The request body is limited to 4 MiB. The CLI applies the same limit to the file in both modes.
• An applied import writes one audit line with the counts (santa: import rules new=N duplicate=N). A dry run and a blocked import write none.
• In DB mode the first santa CLI command creates the Santa tables if they do not exist, even when Santa is disabled on the services. The alert commands already do the same for their tables.
• cmd/api/main.go gains an apiSantaPath constant and the Santa routes use it. Paths are unchanged; the CLI route guard test only recognises named path constants.
• No schema change, and no change to the sync protocol or osctrl-tls. Imported rules change the rule digest, so clients get a clean sync on their next sync, as with any rule change.
Not included
• CSV export. The issue listed it as "if cheap", and JSON covers the round trip.
• An option to import the clean rules and skip the conflicting ones.
Validation
• go test ./pkg/santa/... ./pkg/apiclient/... ./cmd/api/... ./cmd/tls/... ./cmd/cli/...
• go vet, gofmt -l, golangci-lint run ./pkg/santa/... ./pkg/apiclient/... ./cmd/api/... ./cmd/cli/... (0 issues)
• make openapi-check
• npm --prefix frontend run check and npm --prefix frontend test (792 tests)
New tests cover:
• Manager: classification of every case, blocking on conflicts and invalid rules, dry run storing nothing, other environments left untouched, and the export and re-import no-op.
• Handler: bad and oversized bodies, ignored body fields, dry_run, a single audit line, and the env-admin requirement.
• CLI: the import and export round trip in DB and API mode, the non-zero exit on a conflict, and the audit lines.
• Frontend: preview then apply, a blocked import, a file that is not a rule list, and the export contents.
Not verified: the UI in a browser, and the import transaction on PostgreSQL or MySQL (tests run on SQLite). The new strings in the 19 non-English locales are machine-written and not reviewed by native speakers.
jmpsec/osctrlGitHub
11/13/2026, 5:06 PM