fix(jira): correct Data Sensitivity field ID and replicate Jira's real classification scheme
Aegis CI / lint-and-test (push) Has been cancelled
Snyk Security Scan / Python vulnerabilities (backend) (push) Has been cancelled
Snyk Security Scan / npm vulnerabilities (frontend) (push) Has been cancelled
Snyk Security Scan / Docker image vulnerabilities (backend) (push) Has been cancelled
Aegis CI / lint-and-test (push) Has been cancelled
Snyk Security Scan / Python vulnerabilities (backend) (push) Has been cancelled
Snyk Security Scan / npm vulnerabilities (frontend) (push) Has been cancelled
Snyk Security Scan / Docker image vulnerabilities (backend) (push) Has been cancelled
The auto-create-ticket call was sending customfield_11233 (a field that doesn't exist in the project) instead of the real Data Sensitivity field customfield_11814, which made Jira reject the WHOLE issue and silently block ticket creation for every new test. Also replaces Aegis's invented 4-tier data_classification scheme (public_release/general_use/confidential/restricted) with the 6 values Jira's Data Sensitivity field actually uses (public/general_use/ internal_use_only/trusted_people/customer_content/pii), since that is the classification the organization actually applies. Includes a data migration remapping existing rows and a defensive retry if Jira ever rejects an unscreened custom field again.
This commit is contained in:
@@ -79,7 +79,7 @@ JIRA_FIELD_ATTACK_SUCCESS = "customfield_11815"
|
||||
JIRA_FIELD_ATTACK_DETECTED = "customfield_11809"
|
||||
JIRA_FIELD_TIME_TO_DETECT = "customfield_11810"
|
||||
JIRA_FIELD_TIME_TO_CONTAIN = "customfield_11811"
|
||||
JIRA_FIELD_DATA_SENSITIVITY = "customfield_11233"
|
||||
JIRA_FIELD_DATA_SENSITIVITY = "customfield_11814"
|
||||
JIRA_FIELD_ATTACK_CONTAINED = "customfield_11885"
|
||||
|
||||
_ATTACK_SUCCESS_TO_JIRA = {
|
||||
@@ -101,10 +101,12 @@ _CONTAINMENT_TO_JIRA = {
|
||||
}
|
||||
|
||||
_DATA_CLASSIFICATION_TO_JIRA = {
|
||||
"public_release": "Public Release",
|
||||
"public": "Public",
|
||||
"general_use": "General Use",
|
||||
"confidential": "Confidential",
|
||||
"restricted": "Restricted",
|
||||
"internal_use_only": "Internal Use Only",
|
||||
"trusted_people": "Trusted People",
|
||||
"customer_content": "Customer Content",
|
||||
"pii": "PII",
|
||||
}
|
||||
|
||||
# Assign logger = logging.getLogger(__name__)
|
||||
@@ -720,7 +722,23 @@ def auto_create_test_issue(
|
||||
if parent:
|
||||
fields["parent"] = {"key": parent}
|
||||
|
||||
result = jira.issue_create(fields=fields)
|
||||
try:
|
||||
result = jira.issue_create(fields=fields)
|
||||
except Exception as exc:
|
||||
# Jira rejects the whole issue when a custom field isn't on the
|
||||
# project's create screen ("cannot be set ... not on the
|
||||
# appropriate screen"). Don't let a screen-config gap on an
|
||||
# optional field (data sensitivity) block ticket creation
|
||||
# entirely — drop it and retry once.
|
||||
if JIRA_FIELD_DATA_SENSITIVITY in fields and JIRA_FIELD_DATA_SENSITIVITY in str(exc):
|
||||
logger.warning(
|
||||
"Jira rejected %s (not on create screen); retrying without it for test %s",
|
||||
JIRA_FIELD_DATA_SENSITIVITY, test.id,
|
||||
)
|
||||
fields.pop(JIRA_FIELD_DATA_SENSITIVITY)
|
||||
result = jira.issue_create(fields=fields)
|
||||
else:
|
||||
raise
|
||||
issue_key = result["key"]
|
||||
issue_id = result.get("id", "")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user