Skip to content

Commit

Permalink
Merge branch '5.0/apply-cve-id-on-lifecycles' into 5.0-trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnavy committed Oct 16, 2024
2 parents f370f1f + 74df104 commit 03f8d24
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion etc/upgrade/5.0.2/content
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ our @ScripConditions;
our @CustomFields = (
{ Name => 'CVE ID',
Type => 'FreeformMultiple',
Queue => [ 'Incidents', 'Incident Reports', 'Investigations', 'Countermeasures' ],
Disabled => 0,
LookupType => 'RT::Queue-RT::Ticket',
Description => 'CVE ID for RTIR queues',
LinkValueTo => 'https://nvd.nist.gov/vuln/detail/__CustomField__#vulnCurrentDescriptionTitle',
},
Expand Down Expand Up @@ -207,6 +207,28 @@ our @Final = (
}
}
},
sub {
# Apply new CVE ID CF to existing RTIR queues based on lifecycle
my $cve_id_obj = RT::CustomField->new(RT->SystemUser);
my ($ok, $msg) = $cve_id_obj->LoadByName( Name => 'CVE ID' );

if ( $cve_id_obj->IsGlobal ) {
my $empty_queue = RT::Queue->new( RT->SystemUser );
my ($ok, $msg) = $cve_id_obj->RemoveFromObject( $empty_queue );
}

if ( $ok && $cve_id_obj->Id ) {
my $queues = RT::Queues->new(RT->SystemUser);
$queues->Limit( FIELD => 'Lifecycle', VALUE => [ 'incident_reports', 'incidents', 'investigations', 'countermeasures' ], OPERATOR => 'IN' );
while ( my $queue = $queues->Next ) {
my ($ok, $msg) = $cve_id_obj->AddToObject( $queue );
RT->Logger->error("Unable to apply CVE ID to queue " . $queue->Name . " $msg") unless $ok;
}
}
else {
RT->Logger->error("Unable to load custom field CVE ID: $msg");
}
},
);

1;

0 comments on commit 03f8d24

Please sign in to comment.