Repository navigation
feat(security): add security scan and affected resources tasks - #31
Conversation
Part of kestra-io#10 (Security scans slice).
89bb271 to
b178950
Compare
fdelbrayelle
left a comment
There was a problem hiding this comment.
Kestra Plugin Code Review
Business Requirements — met
All five tasks from #30 (Create, Get, GetLatest, List, ListAffectedResources) are added under security.scan, with the severity and type filters, metadata, icon, docs, README and AGENTS.md entries. Settings and suppressions are out of scope as stated in the issue.
Kestra Guidelines — 0 findings
✅ No violations. Lombok annotations, Property<T> inputs, property groups, @Schema, full runnable @Example flows, @PluginSubGroup, metadata yaml, how-to doc and AGENTS.md are all in place. perPage and page bounds are enforced at runtime with requireInRange and documented in @Schema. Path segments are encoded with encodePathSegment. Tests are WireMock-based and run unconditionally, with a happy path for every task.
Security (OWASP Top 10:2025 + KPS) — 0 findings
✅ No issues found. The token goes through the shared base class and the internal HTTP client, and nothing user-supplied is concatenated unencoded into the URL.
Performance — 0 findings
✅ No issues found. List drops findings from each row so the output does not grow with scans times findings, and Get/GetLatest cap the findings at one page of at most 200.
Notes for maintainers (non-blocking)
ListAffectedResources.findingId: the PR says the OpenAPI spec does not state wherefinding_uuidcomes from, and the demo passes a finding'srule_uuid. This was only checked against a local mock, never the real API. Worth a check on a CSPM-enabled account before release, and ifrule_uuidis not accepted, the@Schemadescription offindingIdshould say where to find the right value.
Verdict: APPROVE; recommendation only, posted as COMMENT, a maintainer decides.
QA report: feat(security): add security scan and affected resources tasks (#31)Commit: b178950 Result: PASS. No HIGH or MEDIUM issue found. Bundled
Checked against the request log of the mock: Create sends Flow 1: do31_lifecycle (SUCCESS)Flow YAMLid: do31_lifecycle
namespace: qa.do31
tasks:
- id: create_scan
type: io.kestra.plugin.digitalocean.security.scan.Create
apiToken: "fake-token-for-mock"
baseUrl: "http://mock:8080"
- id: get_scan
type: io.kestra.plugin.digitalocean.security.scan.Get
apiToken: "fake-token-for-mock"
baseUrl: "http://mock:8080"
scanId: "{{ outputs.create_scan.id }}"
- id: latest_scan
type: io.kestra.plugin.digitalocean.security.scan.GetLatest
apiToken: "fake-token-for-mock"
baseUrl: "http://mock:8080"
- id: list_scans
type: io.kestra.plugin.digitalocean.security.scan.List
apiToken: "fake-token-for-mock"
baseUrl: "http://mock:8080"
- id: affected
type: io.kestra.plugin.digitalocean.security.scan.ListAffectedResources
apiToken: "fake-token-for-mock"
baseUrl: "http://mock:8080"
scanId: "{{ outputs.get_scan.id }}"
findingId: "{{ outputs.latest_scan.findings[0].rule_uuid }}"
- id: summary
type: io.kestra.plugin.core.log.Log
message: "create={{ outputs.create_scan.status }} get_findings={{ outputs.get_scan.findings | length }} scans={{ outputs.list_scans.total }} affected={{ outputs.affected.total }}"
Logs synthesis (1.3.43): "Started security scan ... with status IN_PROGRESS", "Scan ... is COMPLETED with 3 finding(s) on page 1" for Get and GetLatest, then List and ListAffectedResources counts. No token in any log line. Outputs synthesis (1.3.43, 2.0.6): Create returns Flow 2: do31_filters (SUCCESS)Flow YAMLid: do31_filters
namespace: qa.do31
tasks:
- id: critical_only
type: io.kestra.plugin.digitalocean.security.scan.GetLatest
apiToken: "fake-token-for-mock"
baseUrl: "http://mock:8080"
severity: CRITICAL
- id: by_type
type: io.kestra.plugin.digitalocean.security.scan.Get
apiToken: "fake-token-for-mock"
baseUrl: "http://mock:8080"
scanId: "22222222-2222-2222-2222-222222222222"
findingType: firewall
- id: page_two
type: io.kestra.plugin.digitalocean.security.scan.Get
apiToken: "fake-token-for-mock"
baseUrl: "http://mock:8080"
scanId: "22222222-2222-2222-2222-222222222222"
perPage: 2
page: 2
- id: check
type: io.kestra.plugin.core.log.Log
message: "critical={{ outputs.critical_only.findings | length }} firewall={{ outputs.by_type.findings | length }} page2={{ outputs.page_two.findings | length }}"Gantt (1.3.43, 2.0.6): all 4 tasks SUCCESS, each under 0.05s. Flow 3: do31_pagination (SUCCESS)Flow YAMLid: do31_pagination
namespace: qa.do31
tasks:
- id: list_paged
type: io.kestra.plugin.digitalocean.security.scan.List
apiToken: "fake-token-for-mock"
baseUrl: "http://mock:8080"
perPage: 2
- id: affected_paged
type: io.kestra.plugin.digitalocean.security.scan.ListAffectedResources
apiToken: "fake-token-for-mock"
baseUrl: "http://mock:8080"
scanId: "22222222-2222-2222-2222-222222222222"
findingId: "aaaaaaaa-0000-0000-0000-000000000001"
perPage: 2
fetchType: FETCH
- id: check
type: io.kestra.plugin.core.log.Log
message: "scans={{ outputs.list_paged.size }}/{{ outputs.list_paged.total }} has_findings={{ outputs.list_paged.rows[0] | keys | join(',') }} affected={{ outputs.affected_paged.size }}"Gantt (1.3.43, 2.0.6): 3 tasks SUCCESS, 0.2s total. Flow 4: do31_notenabled (SUCCESS)Flow YAMLid: do31_notenabled
namespace: qa.do31
tasks:
- id: latest
type: io.kestra.plugin.digitalocean.security.scan.GetLatest
apiToken: "notenabled"
baseUrl: "http://mock:8080"
- id: log
type: io.kestra.plugin.core.log.Log
message: "status={{ outputs.latest.status }} findings={{ outputs.latest.findings | length }}"Gantt (screenshot): both tasks SUCCESS. Flow 5: do31_notfound (FAILED, expected)Flow YAMLid: do31_notfound
namespace: qa.do31
tasks:
- id: get_missing
type: io.kestra.plugin.digitalocean.security.scan.Get
apiToken: "fake-token-for-mock"
baseUrl: "http://mock:8080"
scanId: "missing"Gantt (1.3.43, 2.0.6): Flow 6: do31_badtoken (FAILED, expected)Flow YAMLid: do31_badtoken
namespace: qa.do31
tasks:
- id: unauthorized
type: io.kestra.plugin.digitalocean.security.scan.GetLatest
apiToken: "bad"
baseUrl: "http://mock:8080"Logs synthesis (screenshot): "HTTP 401: invalid or missing API token. Create a personal access token (prefixed dop_v1_) ... and set it as apiToken". The token value is not printed. Flow 7: do31_badperpage (FAILED, expected)Flow YAMLid: do31_badperpage
namespace: qa.do31
tasks:
- id: too_many
type: io.kestra.plugin.digitalocean.security.scan.Get
apiToken: "fake-token-for-mock"
baseUrl: "http://mock:8080"
scanId: "22222222-2222-2222-2222-222222222222"
perPage: 500Logs synthesis (screenshot): "perPage must be between 1 and 200, got 500". Validated before any HTTP call. Flow 8: do31_regression (SUCCESS, non-regression)Flow YAMLid: do31_regression
namespace: qa.do31
tasks:
- id: droplets
type: io.kestra.plugin.digitalocean.droplet.List
apiToken: "fake-token-for-mock"
baseUrl: "http://mock:8080"Outputs synthesis (screenshot): existing Timeout notes: none, every execution finished in under 2s. Topology checks skipped: the PR adds no custom UI or topology node, and the repo has no |
What changes are being made and why?
Closes #30 (part of #10). This is the Security scans slice, after Snapshots (#17), Billing (#18), Block Storage Actions (#23) and Spaces keys (#25).
DigitalOcean's security (CSPM) scans could not be started or read from a flow, e.g. to run a scan on a schedule and fail or alert when it reports critical findings. This adds a
security.scansubgroup on/v2/security/scans:security.scan.Create: starts a scan and returns it without waitingsecurity.scan.Get: reads a scan by ID with its findings, optionally filtered by severity or typesecurity.scan.GetLatest: the same, for the most recent scansecurity.scan.List: lists the scanssecurity.scan.ListAffectedResources: lists the resources a finding applies toCreatefollows the same pattern as the other asynchronous tasks in the plugin: it returns the scan's initial status, andGetinside aLoopUntilwaits for it (see the flow below).Three choices worth flagging:
GetandGetLatestreturn one page of findings (up to 200) and exposepage, instead of paginating on their own: the scan response has nolinksormetain the OpenAPI spec, so there is nothing documented to follow.Listdrops thefindingsfrom each row, so its output doesn't grow with scans times findings. Findings are read withGet.finding_uuidof the affected resources endpoint comes from, and a finding only carries arule_uuid.ListAffectedResourcestakes it as a plainfindingId; the demo below passes therule_uuid, which is what my mock expects. I could not check this against the real API, since I have no account with CSPM enabled.The settings and suppressions endpoints of the Security API are left for a follow-up PR.
Endpoints and fields taken from DigitalOcean's OpenAPI spec, plus the metadata, icon and docs entries for the new subgroup.
How the changes have been QAed?
page, skipping the page size check, sending a different create body, swapping the scan and finding IDs in the path or pointingGetLatestelsewhere each makes a test fail.baseUrlpoints to the mock; drop it to hit the real API):The loop polled the scan three times until it was
COMPLETED, and the summary loggedScan COMPLETED with 1 critical finding(s): "All Firewall Ports Exposed to a Source" affects 2 resource(s), first one do:droplet:3164444. 3 scan(s) on the account.The mock sends findings inside every scan of the list, and thelist_scansrows came out withid,statusandcreated_atonly. A second flow withGetLatestand aFailtask failed as intended with1 critical finding(s), first one: All Firewall Ports Exposed to a Source.Before / after
Plugin list: the new Security Scans group shows up. The "before" side is the released plugin, so it also lacks the Snapshots and Billing groups merged this week.
Editor: the released plugin rejects
security.scan.Create, this branch validates it.The demo flow running end to end.
Setup Instructions
A DigitalOcean API token in a
DIGITALOCEAN_TOKENsecret, with thesecurity:createscope forCreateandsecurity:readfor the other tasks, on an account with CSPM enabled.Contributor Checklist ✅