Skip to content

Commit

Permalink
Apply CVE ID based on lifecycle rather than queue name
Browse files Browse the repository at this point in the history
RTIR systems can have multiple sets of RTIR queues with
different names for the queues. On upgrade, CVE ID on
these systems won't be applied to renamed queues.

Apply based on lifecycle to find all RTIR queues.
  • Loading branch information
cbrandtbuffalo committed Oct 16, 2024
1 parent f370f1f commit 74df104
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 74df104

Please sign in to comment.