<& Elements/Header, Title => loc("Results") &> <& /Elements/ListActions, actions => \@results &> % if($#submitted > -1){ % if($#submitted == 0){ % my $url = '3;url='.RT->Config->Get('WebURL')."Minimal/Display.html?id=".$submitted[0]; " /> % } else { % my $sc = RT::Tickets->new($session{'CurrentUser'}); % foreach (@submitted){ % $sc->Limit(FIELD => 'id', VALUE => $_, ENTRYAGGREGATOR => 'OR', OPPERATOR => '='); % } <& /Elements/CollectionList, title => loc('Results'), Collection => $sc, Format => $Format, Order => @Order, OrderBy => @OrderBy, Class => 'RT::Tickets', Rows => $Rows, Page => $Page, AllowSorting => $AllowSorting, &> % } % } <%INIT> unless($data){ RT::Interface::Web::Redirect(RT->Config->Get('WebURL').'Minimal/Observation.html'); } my $Format = qq{ '__id__/TITLE:#', '__Subject__/TITLE:Subject', Created, LastUpdated, }; require XML::IODEF::Simple; require CIF::Utils; my $max_submissions = RT->Config->Get('CIFMinimal_MaxSubmissions') || 15; # just in case someone tries to set it on their own # w/o the proper rights my $d_confidence = RT->Config->Get('CIFMinimal_DefaultConfidence') || 85; if($confidence > $d_confidence){ $confidence = $d_confidence unless($session{'CurrentUser'}->Privileged()); } #my $guid = (CIF::Utils::isUUID($group)) ? $group : CIF::Utils::genSourceUUID($group); my $guid = $group; my $constituency_cf = RT::IR->CustomFields( 'Constituency', Queue => $Queue ); my $constituency_field = 'Object-RT::Ticket--CustomField-' . $constituency_cf->id .'-Values'; $ARGS{$constituency_field} = $group; my $real_assessment = $assessment; $real_assessment =~ s/\/\S+$//; my @datas = split(/,/,$data); my @submitted; my %entered; if($#datas < $max_submissions){ foreach $data (@datas){ $data =~ s/[ \t]+$//g; $data =~ s/^[ \t]+//g; $data = lc($data); my $hash = { guid => $guid, restriction => $restriction, description => $description, impact => $real_assessment, address => $data, protocol => $protocol, portlist => $portlist, source => $session{'CurrentUser'}->EmailAddress(), contact => { name => $session{'CurrentUser'}->RealName(), email => $session{'CurrentUser'}->EmailAddress(), }, purpose => $purpose, confidence => $confidence, sharewith => $sharewith, }; my $report = XML::IODEF::Simple->new($hash); $description = $report->get('IncidentDescription'); my $subject = $report->get('IncidentAssessmentImpact').' '.$description; my $msg = $report->out(); $ARGS{'Subject'} = $subject; $ARGS{'Queue'} = 'Incident Reports'; if($entered{$data}){ # we call this the 'gabe' clause push(@results,'skipping duplicate: '.$data); } else { my ($ticket,@res) = CreateTicket(Content => $msg, Attachments => $session{'Attachments'}, %ARGS, Status => 'new'); $ticket->Comment(Content => $ARGS{'ReferenceDescription'}); if($ticket->Status() eq 'rejected'){ push(@results,'Ticket contained bad-data (private address?), auto-rejected'); } else { $entered{$data} = 1; push(@submitted,$ticket->Id()); my $rr = 'Ticket '.$ticket->Id().' Created -- '.$ticket->Subject(); push(@results,$rr); #push(@results,$msg) if(RT->Config->Get('LogToSyslog') eq 'debug'); require CIF::Archive; require CIF::FeedParser::ParseJsonIodef; require JSON; my $r = $ticket->IODEF(); my $ret = CIF::FeedParser::ParseJsonIodef::parse(undef,JSON::to_json([$r->to_tree()])); foreach(@$ret){ $_->{'detcttime'} = $ticket->CreatedAsString(); my ($err,$id) = CIF::Archive->insert($_); warn $err if($err); warn $id if($id); } } } } } else { push(@results,'Error: Too many entries for a single submission'); push(@results,'This server configured to handle: '.$max_submissions.' entries per submission'); push(@results,'Please either break-up the submission or contact the administrators for bulk submission options'); } <%ARGS> $sharewith => undef $group => undef $purpose => RT->Config->Get('CIFMinimal_DefaultPurpose') || 'mitigation' $data => undef $restriction => undef $description => undef $protocol => undef $portlist => undef @results => undef $assessment => undef $Queue => 'Incident Reports' $confidence => RT->Config->Get('CIFMinimal_DefaultConfidence') || 85 $Collection => undef $Page => 1 $AllowSorting => 1 @Order => ('DESC') @OrderBy => ('Created') $Rows => 50