Skip to content

Adding new values to extensible list-type custom tags in SSC issue update during remediation#994

Open
jmadhur87 wants to merge 1 commit intofortify:dev/v3.xfrom
jmadhur87:mjain/959
Open

Adding new values to extensible list-type custom tags in SSC issue update during remediation#994
jmadhur87 wants to merge 1 commit intofortify:dev/v3.xfrom
jmadhur87:mjain/959

Conversation

@jmadhur87
Copy link
Copy Markdown
Contributor

This PR enhances the SSC issue update command used during remediation to support adding new values to custom tags of type list when the tag is marked as extensible=true using new option --extend.
ssc issue update --extend

While verifying for ssc tag update command, found that value updates for non-LIST custom tags (TEXT, DECIMAL, DATE) were incorrectly reported as Updated in fcli, even though SSC made no change.
Added explicit validation and a clear error message so these unsupported value operations now fail fast instead of showing a false success.

Fix: Support adding new values to extensible list-type custom tags in SSC issue update during remediation(#959 )

Copy link
Copy Markdown
Contributor

@SangameshV SangameshV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also please check whether the SSCCustomTagDescriptor requires extensible field

SSCCustomTagDescriptor desc = getDescriptorByCustomTagSpec(tagGuid, true);
ObjectNode body = (ObjectNode) desc.asJsonNode().deepCopy();
LinkedHashMap<String, ObjectNode> valueMap = buildValueMap(body);
if (!valueMap.containsKey(newValue)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A case mismatch in the keys can create duplicate list values in SSC. The buildValueMap method returns the listValues map with lowercase keys, and the containsKey check always returns false due to the case difference, thereby allowing duplicate list values to be added to the overall list.

Note: The same bug would cascade into extendTagWithValue, which caches the returned newLookupIndex in tagInfo.getValueList() a wrong index would be reused for all subsequent issues in the same command run.

}

private int extendTagWithValue(CustomTagInfo tagInfo, String newValue) {
int newIndex = new SSCCustomTagDefinitionHelper(unirest).addValueToListTag(tagInfo.getGuid(), newValue);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The addValueToListTag makes a redundant full GET /customTags call.

extendTagWithValue in SSCIssueCustomTagHelper creates a new SSCCustomTagDefinitionHelper instance that triggers lazy-loading of all custom tags via GET /api/v1/customTags?limit=-1 just to get the descriptor for one tag. A targeted GET /api/v1/customTags/{id} would be more efficient.

private String comment;
@Option(names = {"--assign-user"})
private String assignUser;
@Option(names = {"--extend"}, defaultValue = "false")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--extend at issue update level, not per-tag.
If updating multiple custom tags in one command (e.g. --custom-tags TagA=NewVal,TagB=ExistingVal), which custom tag the --extend applies to? What if a custom tag is not extensible?
For the extensible custom-tag it should add a value and for the not extensible tags, proper error message must be displayed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants