-
Notifications
You must be signed in to change notification settings - Fork 33
Prepare command upgraded ssc #1025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feat/v3.x/aviator/26.3
Are you sure you want to change the base?
Changes from all commits
526e587
96c5a1a
e1a579f
367dcdc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,9 +14,11 @@ | |
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| import com.fasterxml.jackson.databind.JsonNode; | ||
| import com.formkiq.graalvm.annotations.Reflectable; | ||
| import com.fortify.cli.aviator.ssc.helper.AviatorSSCCustomTagHelper.SynchronizationResult; | ||
| import com.fortify.cli.common.json.JsonHelper; | ||
| import com.fortify.cli.common.progress.helper.IProgressWriter; | ||
| import com.fortify.cli.common.progress.helper.ProgressWriterType; | ||
|
|
@@ -70,27 +72,40 @@ public PrepareResult prepare(PrepareOptions options) { | |
| var tagHelperStatus = new AviatorSSCCustomTagHelper(unirest, AviatorSSCTagDefs.AVIATOR_STATUS_TAG); | ||
| var tagHelperDastCorr = new AviatorSSCCustomTagHelper(unirest, AviatorSSCTagDefs.DAST_CORRELATION_STATUS_TAG); | ||
|
|
||
| JsonNode predictionTag = tagHelperPrediction.synchronize(result); | ||
| JsonNode statusTag = tagHelperStatus.synchronize(result); | ||
| JsonNode dastCorrTag = tagHelperDastCorr.synchronize(result); | ||
| SynchronizationResult predictionResult = tagHelperPrediction.synchronize(result); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method is quite long; can this be split into multiple methods? |
||
| SynchronizationResult statusResult = tagHelperStatus.synchronize(result); | ||
| SynchronizationResult dastCorrResult = tagHelperDastCorr.synchronize(result); | ||
|
|
||
| if (predictionTag == null || statusTag == null) { | ||
| // Required Aviator tags must succeed (either as custom or system-managed) | ||
| if (!predictionResult.isSuccessful() || !statusResult.isSuccessful()) { | ||
| result.addEntry("Global", "HALTED", "Failed to synchronize one or more required Aviator custom tags."); | ||
| return result; | ||
| } | ||
| if (dastCorrTag == null) { | ||
| // DAST correlation tag is optional - just warn if it fails | ||
| if (!dastCorrResult.isSuccessful()) { | ||
| result.addEntry("DAST Correlation Tag", "WARNING", | ||
| "Failed to synchronize 'DAST correlation status' tag. SAST-DAST correlation feature may not be fully visible in SSC UI."); | ||
| } | ||
|
|
||
| // Always synchronize attributes (before any early return) | ||
| progress.writeProgress("Synchronizing Aviator custom attributes..."); | ||
| new AviatorSSCCorrelationAttributeHelper(unirest, AviatorSSCCorrelationAttributeDefs.LAST_CORRELATION_ATTR) | ||
| .synchronize(result); | ||
|
|
||
| // Build required tags list — include dastCorrTag only if successfully synchronized | ||
| List<JsonNode> requiredTags = dastCorrTag != null | ||
| ? List.of(predictionTag, statusTag, dastCorrTag) | ||
| : List.of(predictionTag, statusTag); | ||
| // Build list of tags requiring manual association (excludes system-managed tags) | ||
| List<SynchronizationResult> allResults = List.of(predictionResult, statusResult, dastCorrResult); | ||
| List<JsonNode> requiredTags = allResults.stream() | ||
| .filter(SynchronizationResult::requiresAssociation) | ||
| .map(SynchronizationResult::getTag) | ||
| .collect(Collectors.toList()); | ||
|
|
||
| // If all Aviator tags are system-managed (SSC 26.2+), skip template/version association | ||
| if (requiredTags.isEmpty()) { | ||
| result.addEntry("Global", "INFO", | ||
| "All Aviator tags are system-managed (SSC 26.2+). No manual template/version association required."); | ||
| progress.writeInfo("All Aviator tags are system-managed by SSC. No manual association needed."); | ||
| return result; | ||
| } | ||
|
|
||
| if (options.isAllIssueTemplates() || options.getIssueTemplateNameOrId() != null) { | ||
| new AviatorSSCTemplateUpdater(unirest).process(options, result, requiredTags, progress); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -161,10 +161,13 @@ fcli.aviator.ssc.apply-remediations.since = Filter artifacts by upload date. Sup | |
| Can only be used with --latest or --all; not compatible with --artifact-id. | ||
|
|
||
| fcli.aviator.ssc.prepare.usage.header = (PREVIEW) Prepare an SSC instance for Fortify Remediation Aviator integration. | ||
| fcli.aviator.ssc.prepare.usage.description = This command ensures that the Fortify Remediation Aviator-specific custom tags ('Aviator prediction',`Aviator status`) \ | ||
| fcli.aviator.ssc.prepare.usage.description = This command ensures that the Fortify Remediation Aviator-specific custom tags ('Aviator prediction', 'Aviator status') \ | ||
| exist in SSC and are associated with the specified issue templates and/or application versions. \ | ||
| This is necessary to prevent SSC from stripping Fortify Remediation Aviator audit data from uploaded FPR files. \ | ||
| At least one update option must be specified. \ | ||
| %n%nFor SSC 26.2 and later, Aviator tags are built-in system-managed tags that are automatically associated with all \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it was mentioned that these system-managed tags are only available if Aviator is enabled in SSC configuration, correct? If so, would be good to explicitly mention this in fcli usage help. |
||
| issue templates and application versions. In this case, the command will detect the system-managed tags and skip \ | ||
| manual association. For older SSC versions, the tags are created as custom tags and must be manually associated. \ | ||
| %n%nAt least one update option must be specified. \ | ||
| %n%nNOTE\: This command is considered preview functionality as it will likely change in a future fcli version \ | ||
| to re-use generic tag update functionality that is planned for the fcli ssc module. | ||
| fcli.aviator.ssc.prepare.issue-template = Update a single issue template by its name or ID. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method seems fairly long; please check whether it's feasible to refactor into multiple focused methods.