Repository navigation
feat(security): add security settings, suppression and scan rule tasks - #43
Conversation
fdelbrayelle
left a comment
There was a problem hiding this comment.
Kestra Plugin Code Review
Business Requirements: met
All five tasks listed in #32 are present (security.settings.Get, UpdatePlan, CreateSuppression, DeleteSuppression, security.scan.CreateRule). Paths, methods, request bodies, response shapes and the per_page/page parameters match DigitalOcean's current OpenAPI spec. No build, dependency or CI changes.
Kestra Guidelines: 3 findings
- 🟢
CreateRule.java:30[Guidelines] Schema descriptions not in text blocks - 🟢
SuppressionPage.java:23[Guidelines] Explicit local type wherevarworks - 🟢
CreateSuppression.java:118[Guidelines] Output count named differently fromGet
Security (OWASP Top 10:2025 + KPS): 0 findings
✅ No issues found
Performance: 0 findings
✅ No issues found
Local check at f5c8659: the 5 new test classes ran, 21/21 passed. CI (Main, Security scan) is green.
Verdict: APPROVE; recommendation only, posted as COMMENT, a maintainer decides.
Confidence: 97% (100 - 1 Nit - 1 Nit - 1 Nit)
| @NoArgsConstructor | ||
| @Schema( | ||
| title = "Exclude a resource from DigitalOcean security scans", | ||
| description = "Creates a scan rule that excludes a resource from future security (CSPM) scans, e.g. to mark the " + |
There was a problem hiding this comment.
🟢 [Guidelines] Schema descriptions not in text blocks
Problem: The new @Schema(description = ...) values use single-line strings or + concatenation, while the guidelines ask for """ text blocks for documentation; this applies to all new classes in this PR (Get, UpdatePlan, CreateSuppression, DeleteSuppression, TierCoverage).
Fix: Switch the descriptions to text blocks, e.g. description = """ followed by the text on its own lines. Optional, the existing classes in the repo use the same style.
| .filter(Objects::nonNull) | ||
| .toList(); | ||
| var meta = asMap(block.get("meta")); | ||
| long total = meta != null && meta.get("total") instanceof Number number ? number.longValue() : rows.size(); |
There was a problem hiding this comment.
🟢 [Guidelines] Explicit local type where var works
Problem: long total = ... declares an explicit type although the ternary already resolves to long, against the var for all locals rule.
Fix: var total = meta != null && meta.get("total") instanceof Number number ? number.longValue() : rows.size();
| private final List<Map<String, Object>> suppressions; | ||
|
|
||
| @Schema(title = "Total suppressions", description = "Number of suppressions reported by the DigitalOcean API (meta.total).") | ||
| private final Long total; |
There was a problem hiding this comment.
🟢 [Guidelines] Output count named differently from Get
Problem: The same meta.total value is exposed as total here and as suppressionsTotal on security.settings.Get, so a flow using both tasks has to remember two names for the same thing.
Fix: Rename to suppressionsTotal (and the builder call at line 103) so both tasks match.
QA report: plugin-digitalocean PR 43 (security settings, suppressions, scan rule)Commit: f5c8659 Setup: shadow JAR built from the PR head (build files unchanged vs main, no Results
Flows 4 to 8 are negative scenarios: PASS means the task failed as intended. Requests recorded by the mock (2.0.7 run)All requests carried Flow 3: suppression_lifecycle (SUCCESS, 0.55s on 1.3.44, 0.35s on 2.0.7)Flow YAMLid: suppression_lifecycle
namespace: qa.do43
tasks:
- id: suppress
type: io.kestra.plugin.digitalocean.security.settings.CreateSuppression
apiToken: fake-do-token-qa
baseUrl: http://qa-do43-mock:8099
ruleId: bbbbbbbb-0000-4000-8000-000000000009
resources:
- do:droplet:11111111-2222-4333-8444-555555555555
- do:droplet:66666666-2222-4333-8444-555555555555
- id: delete
type: io.kestra.plugin.digitalocean.security.settings.DeleteSuppression
apiToken: fake-do-token-qa
baseUrl: http://qa-do43-mock:8099
suppressionId: "{{ outputs.suppress.suppressions[0].id }}"
- id: update_plan
type: io.kestra.plugin.digitalocean.security.settings.UpdatePlan
apiToken: fake-do-token-qa
baseUrl: http://qa-do43-mock:8099
tierCoverage:
basic:
tags: [production]
resources: [do:droplet:fe3a2fd7-903d-46e6-ada3-3e4f285fb89d]
advanced:
tags: [staging]
- id: rule
type: io.kestra.plugin.digitalocean.security.scan.CreateRule
apiToken: fake-do-token-qa
baseUrl: http://qa-do43-mock:8099
resource: do:droplet:fe3a2fd7-903d-46e6-ada3-3e4f285fb89d
- id: log
type: io.kestra.plugin.core.log.Log
message: "created {{ outputs.suppress.suppressions | length }} total={{ outputs.suppress.total }} plan={{ outputs.update_plan.tierCoverage }}"
Logs synthesis: "Suppressing ... on 2 resource(s)", "Removing ... suppression ", "Updating ... tier(s) [basic, advanced]", "Excluding do:droplet:... from DigitalOcean security scans". Outputs synthesis: Flow 2: get_paged (SUCCESS)Flow YAMLid: get_paged
namespace: qa.do43
tasks:
- id: p1
type: io.kestra.plugin.digitalocean.security.settings.Get
apiToken: fake-do-token-qa
baseUrl: http://qa-do43-mock:8099
perPage: 2
page: 1
- id: p3 # same task, page: 3
- id: p4 # same task, page: 4
- id: log
type: io.kestra.plugin.core.log.Log
message: "p1={{ outputs.p1.suppressions | length }} p3={{ outputs.p3.suppressions | length }} p4={{ outputs.p4.suppressions | length }} total={{ outputs.p1.suppressionsTotal }}"(p3 and p4 repeat the p1 block with Logs (1.3.44, 2.0.7): "Read 2 of 5 suppression(s) on page 1", page 3 returns 2 rows, page 4 returns 0 rows. On 1.3.44 the totals shown (5, 7, 6) differ between pages only because the mock state was being changed by flow 3 running at the same time. That is a mock artifact, not a plugin issue; on 2.0.7 the runs were sequential and consistent. Flow 1: get_defaults (outputs)SUCCESS. Output keys: Flows 4 to 8 (negative)
Flow 9: droplet_get_regression (SUCCESS, gantt)
FindingsIntroduced by this PR: none found at any severity. Pre-existing: none observed. Observation (LOW, informational, not a defect): on a 4xx the task logs the failing response at ERROR and a TRACE stack trace; the user-facing message is clear. Not testable / limits
|
What changes are being made and why?
Closes #32 (part of #10). This is the second half of the Security section of #10, after the scans in #31, and the last piece of #10 on my side.
The scans from #31 report findings, but a flow could not act on them: choose which resources each plan tier scans, silence a rule on a resource that is fine by design, or keep a resource out of future scans. This adds a
security.settingssubgroup on/v2/security/settings, plus the scan rule endpoint next to the scans:security.settings.Get: reads the settings, with the tier coverage, the scheduled plan downgrades and one page of rule suppressionssecurity.settings.UpdatePlan: sets the resources and tags each plan tier scanssecurity.settings.CreateSuppression: suppresses a rule on a list of resourcessecurity.settings.DeleteSuppression: removes a suppressionsecurity.scan.CreateRule: excludes a resource from future scansTwo choices worth flagging:
/v2/security/settings, so this is one subgroup instead of two, and "List Settings" becameGet, since it returns one object.CreateRulelives insecurity.scanbecause its endpoint is/v2/security/scans/rules.GetexposespageandperPage(up to 200) for the suppressions instead of paginating on its own: thelinks.nextof the response points toGET /v2/security/settings/suppressions, which is not in the OpenAPI spec, so there is nothing documented to follow.Endpoints, bodies and scopes taken from DigitalOcean's OpenAPI spec (checked again against today's version), plus the metadata, icon and docs entries for the new subgroup. As with #31, I could not run it against the real API, since I have no account with CSPM enabled.
How the changes have been QAed?
./gradlew javadocis clean.baseUrlpoints to the mock; drop it to hit the real API):All nine tasks succeeded. The mock received the calls as the spec describes them:
PUT /v2/security/settings/planwith thetier_coverage,POST /v2/security/scans/ruleswith theresource,POST /v2/security/settings/suppressionswith therule_uuidandresources, and theDELETEon the suppression ID returned byCreateSuppression. Thereporttask logged1 suppression(s): Droplet Backups Not Enabled on Droplet fe3a2fd7-903d-46e6-ada3-3e4f285fb89d; basic tier tags ["production"], and theAssertat the end checked 0, 1 and 0 suppressions before, after and once the suppression was lifted.Before / after
Editor: the plugin before this PR rejects
security.settings.Get, this branch validates the flow.Screenshots
The new Security Settings group in the plugin docs.
The demo flow running end to end, and its logs.
Setup Instructions
A DigitalOcean API token in a
DIGITALOCEAN_TOKENsecret, on an account with CSPM enabled, with thesecurity:readscope forGet,security:updateforUpdatePlan,security:createforCreateSuppressionandCreateRule, andsecurity:deleteforDeleteSuppression.Contributor Checklist ✅