99 define(
"REPORT_AGENT_NAME",
"unifiedreport");
117 include_once(__DIR__ .
"/version.php");
118 include_once(__DIR__ .
"/reportStatic.php");
119 include_once(__DIR__ .
"/reportSummary.php");
197 "borderColor" =>
"000000",
236 function __construct()
238 $this->cpClearedGetter =
new XpClearedGetter(
"copyright",
"statement");
252 $this->uploadDao = $this->container->get(
"dao.upload");
253 $this->userDao = $this->container->get(
"dao.user");
267 $licenses = $this->licenseClearedGetter->getCleared($uploadId,
$groupId,
true, null,
false, $this);
268 $this->
heartbeat(empty($licenses) ? 0 : count($licenses[
"statements"]));
270 $licensesMain = $this->licenseMainGetter->getCleared($uploadId,
$groupId,
true, null,
false, $this);
271 $this->
heartbeat(empty($licensesMain) ? 0 : count($licensesMain[
"statements"]));
273 $licensesHist = $this->licenseClearedGetter->getLicenseHistogramForReport($uploadId,
$groupId,
true, null,
false, $this);
274 $this->
heartbeat(empty($licensesHist) ? 0 : count($licensesHist[
"statements"]));
276 $bulkLicenses = $this->bulkMatchesGetter->getCleared($uploadId,
$groupId,
true, null,
false, $this);
277 $this->
heartbeat(empty($bulkLicenses) ? 0 : count($bulkLicenses[
"statements"]));
279 $this->licenseClearedGetter->setOnlyAcknowledgements(
true);
280 $licenseAcknowledgements = $this->licenseClearedGetter->getCleared($uploadId,
$groupId,
true, null,
false, $this);
281 $this->
heartbeat(empty($licenseAcknowledgements) ? 0 : count($licenseAcknowledgements[
"statements"]));
283 $this->licenseClearedGetter->setOnlyComments(
true);
284 $licenseComments = $this->licenseClearedGetter->getCleared($uploadId,
$groupId,
true, null,
false, $this);
285 $this->
heartbeat(empty($licenseComments) ? 0 : count($licenseComments[
"statements"]));
287 $licensesIrre = $this->licenseIrrelevantGetter->getCleared($uploadId,
$groupId,
true, null,
false, $this);
288 $this->
heartbeat(empty($licensesIrre) ? 0 : count($licensesIrre[
"statements"]));
290 $licensesIrreComment = $this->licenseIrrelevantCommentGetter->getCleared($uploadId,
$groupId,
true, null,
false, $this);
291 $this->
heartbeat(empty($licensesIrreComment) ? 0 : count($licensesIrreComment[
"statements"]));
293 $licensesDNU = $this->licenseDNUGetter->getCleared($uploadId,
$groupId,
true, null,
false, $this);
294 $this->
heartbeat(empty($licensesDNU) ? 0 : count($licensesDNU[
"statements"]));
296 $licensesDNUComment = $this->licenseDNUCommentGetter->getCleared($uploadId,
$groupId,
true, null,
false, $this);
297 $this->
heartbeat(empty($licensesDNUComment) ? 0 : count($licensesDNUComment[
"statements"]));
299 $copyrights = $this->cpClearedGetter->getCleared($uploadId,
$groupId,
true,
"copyright",
true, $this);
300 $this->
heartbeat(empty($copyrights[
"statements"]) ? 0 : count($copyrights[
"statements"]));
302 $ecc = $this->eccClearedGetter->getCleared($uploadId,
$groupId,
true,
"ecc",
false, $this);
303 $this->
heartbeat(empty($ecc) ? 0 : count($ecc[
"statements"]));
305 $otherStatement = $this->otherGetter->getReportData($uploadId);
306 $this->
heartbeat(empty($otherStatement) ? 0 : count($otherStatement));
307 $otherStatement[
'includeDNU'] = (count($licensesDNU[
"statements"]) > 0) ?
true :
false;
310 "licenses" => $licenses,
311 "bulkLicenses" => $bulkLicenses,
312 "licenseAcknowledgements" => $licenseAcknowledgements,
313 "licenseComments" => $licenseComments,
314 "copyrights" => $copyrights,
316 "licensesIrre" => $licensesIrre,
317 "licensesIrreComment" => $licensesIrreComment,
318 "licensesDNU" => $licensesDNU,
319 "licensesDNUComment" => $licensesDNUComment,
320 "licensesMain" => $licensesMain,
321 "licensesHist" => $licensesHist,
322 "otherStatement" => $otherStatement
338 $topHeading = array(
"size" => 22,
340 "underline" =>
"single" 343 $mainHeading = array(
"size" => 20,
348 $subHeading = array(
"size" => 16,
352 $subSubHeading = array(
"size" => 14,
356 $paragraphStyle = array(
"spaceAfter" => 0,
361 $phpWord->addNumberingStyle(
'hNum',
362 array(
'type' =>
'multilevel',
'levels' => array(
363 array(
'pStyle' =>
'Heading01',
'format' =>
'bullet',
'text' =>
''),
364 array(
'pStyle' =>
'Heading2',
'format' =>
'decimal',
'text' =>
'%2.'),
365 array(
'pStyle' =>
'Heading3',
'format' =>
'decimal',
'text' =>
'%2.%3.'),
366 array(
'pStyle' =>
'Heading4',
'format' =>
'decimal',
'text' =>
'%2.%3.%4.'),
372 $phpWord->setDefaultFontName(
"Arial");
373 $phpWord->addTitleStyle(1, $topHeading, array(
'numStyle' =>
'hNum',
'numLevel' => 0));
374 $phpWord->addTitleStyle(2, $mainHeading, array(
'numStyle' =>
'hNum',
'numLevel' => 1));
375 $phpWord->addTitleStyle(3, $subHeading, array(
'numStyle' =>
'hNum',
'numLevel' => 2));
376 $phpWord->addTitleStyle(4, $subSubHeading, array(
'numStyle' =>
'hNum',
'numLevel' => 3));
377 $phpWord->addParagraphStyle(
"pStyle", $paragraphStyle);
380 $properties = $phpWord->getDocInfo();
381 $properties->setCreator($userName);
382 $properties->setCompany(
"Your Organisation");
383 $properties->setTitle(
"Clearing Report");
384 $properties->setDescription(
"OSS clearing report by Fossology tool");
385 $properties->setSubject(
"Copyright (C) ".date(
"Y", $timestamp).
", Your Organisation");
397 $secondColLen = 9500;
400 $section->addTitle(htmlspecialchars(
"Main Licenses"), 2);
401 $section->addText($titleSubHeading, $this->subHeadingStyle);
403 $table = $section->addTable($this->tablestyle);
404 if (!empty($mainLicenses)) {
405 foreach ($mainLicenses as $licenseMain) {
406 if ($licenseMain[
"risk"] ==
"4" || $licenseMain[
"risk"] ==
"5") {
407 $styleColumn = array(
"bgColor" =>
"F9A7B0");
408 } elseif ($licenseMain[
"risk"] ==
"2" || $licenseMain[
"risk"] ==
"3") {
409 $styleColumn = array(
"bgColor" =>
"FEFF99");
411 $styleColumn = array(
"bgColor" =>
"FFFFFF");
413 $table->addRow($this->rowHeight);
414 $cell1 = $table->addCell($firstColLen, $styleColumn);
415 $cell1->addText(htmlspecialchars($licenseMain[
"content"], ENT_DISALLOWED), $this->licenseColumn,
"pStyle");
416 $cell2 = $table->addCell($secondColLen);
418 $licenseText = str_replace(
"\n",
"<w:br/>\n", htmlspecialchars($licenseMain[
"text"], ENT_DISALLOWED));
419 $cell2->addText($licenseText, $this->licenseTextColumn,
"pStyle");
420 if (!empty($licenseMain[
"files"])) {
421 $cell3 = $table->addCell($thirdColLen, $styleColumn);
422 asort($licenseMain[
"files"]);
423 foreach ($licenseMain[
"files"] as $fileName) {
424 $cell3->addText(htmlspecialchars($fileName), $this->filePathColumn,
"pStyle");
427 $cell3 = $table->addCell($thirdColLen, $styleColumn)->addText(
"");
431 $table->addRow($this->rowHeight);
432 $table->addCell($firstColLen)->addText(
"");
433 $table->addCell($secondColLen)->addText(
"");
434 $table->addCell($thirdColLen)->addText(
"");
436 $section->addTextBreak();
450 $secondColLen = 9500;
452 if (!empty($title)) {
453 $section->addTitle(htmlspecialchars($title), 2);
455 $section->addText($titleSubHeading, $this->subHeadingStyle);
457 $table = $section->addTable($this->tablestyle);
458 if (!empty($licenses)) {
459 foreach ($licenses as $licenseStatement) {
460 $table->addRow($this->rowHeight);
461 $cell1 = $table->addCell($firstColLen, null,
"pStyle");
462 $cell1->addText(htmlspecialchars($licenseStatement[
"content"], ENT_DISALLOWED), $this->licenseColumn,
"pStyle");
463 $cell2 = $table->addCell($secondColLen,
"pStyle");
465 $licenseText = str_replace(
"\n",
"<w:br/>\n", htmlspecialchars($licenseStatement[
"text"], ENT_DISALLOWED));
466 $cell2->addText($licenseText, $this->licenseTextColumn,
"pStyle");
467 $cell3 = $table->addCell($thirdColLen, null,
"pStyle");
468 asort($licenseStatement[
"files"]);
469 foreach ($licenseStatement[
"files"] as $fileName) {
470 $cell3->addText(htmlspecialchars($fileName), $this->filePathColumn,
"pStyle");
474 $table->addRow($this->rowHeight);
475 $table->addCell($firstColLen)->addText(
"");
476 $table->addCell($secondColLen)->addText(
"");
477 $table->addCell($thirdColLen)->addText(
"");
479 $section->addTextBreak();
490 private function licensesTable(Section $section, $title, $licenses, $riskarray, $titleSubHeading)
493 $secondColLen = 9500;
497 $section->addTitle(htmlspecialchars($title), 2);
498 $section->addText($titleSubHeading, $this->subHeadingStyle);
500 $table = $section->addTable($this->tablestyle);
501 if (!empty($licenses)) {
502 foreach ($licenses as $licenseStatement) {
503 if (in_array($licenseStatement[
'risk'], $riskarray[
'riskLevel'])) {
505 $table->addRow($this->rowHeight);
506 $cell1 = $table->addCell($firstColLen, $riskarray[
'color']);
507 $cell1->addText(htmlspecialchars($licenseStatement[
"content"], ENT_DISALLOWED), $this->licenseColumn,
"pStyle");
508 $cell2 = $table->addCell($secondColLen);
510 $licenseText = str_replace(
"\n",
"<w:br/>\n", htmlspecialchars($licenseStatement[
"text"], ENT_DISALLOWED));
511 $cell2->addText($licenseText, $this->licenseTextColumn,
"pStyle");
512 $cell3 = $table->addCell($thirdColLen, $riskarray[
'color']);
513 asort($licenseStatement[
"files"]);
514 foreach ($licenseStatement[
"files"] as $fileName) {
515 $cell3->addText(htmlspecialchars($fileName), $this->filePathColumn,
"pStyle");
523 if (empty($emptyFlag)) {
524 $table->addRow($this->rowHeight);
525 $table->addCell($firstColLen)->addText(
"");
526 $table->addCell($secondColLen)->addText(
"");
527 $table->addCell($thirdColLen)->addText(
"");
529 $section->addTextBreak();
542 $smallRowHeight = 50;
544 $secondColLen = 5000;
546 $textStyle = array(
"size" => 10,
"bold" =>
true);
548 $section->addTitle(htmlspecialchars($title), 2);
550 $section->addText($text, $textStyle);
552 $section->addText($titleSubHeading, $this->subHeadingStyle);
554 $table = $section->addTable($this->tablestyle);
555 if (!empty($statementsCEI)) {
556 foreach ($statementsCEI as $statements) {
557 if (!empty($statements[
'content'])) {
558 $table->addRow($smallRowHeight);
559 $cell1 = $table->addCell($firstColLen);
560 $text = html_entity_decode($statements[
'content']);
561 $cell1->addText(htmlspecialchars($text, ENT_DISALLOWED), $this->licenseTextColumn,
"pStyle");
562 $cell2 = $table->addCell($secondColLen);
563 $cell2->addText(htmlspecialchars($statements[
'comments'], ENT_DISALLOWED), $this->licenseTextColumn,
"pStyle");
564 $cell3 = $table->addCell($thirdColLen);
565 asort($statements[
"files"]);
566 foreach ($statements[
'files'] as $fileName) {
567 $cell3->addText(htmlspecialchars($fileName), $this->filePathColumn,
"pStyle");
572 $table->addRow($this->rowHeight);
573 $table->addCell($firstColLen)->addText(
"");
574 $table->addCell($secondColLen)->addText(
"");
575 $table->addCell($thirdColLen)->addText(
"");
577 $section->addTextBreak();
590 $secondColLen = 5000;
593 $section->addTitle(htmlspecialchars($title), 2);
594 $section->addText($titleSubHeading, $this->subHeadingStyle);
596 $table = $section->addTable($this->tablestyle);
597 if (!empty($licensesIrre)) {
598 foreach ($licensesIrre as $statements) {
599 $table->addRow($rowWidth,
"pStyle");
600 $cell1 = $table->addCell($firstColLen)->addText(htmlspecialchars($statements[
'content']),null,
"pStyle");
601 $cell2 = $table->addCell($secondColLen)->addText(htmlspecialchars($statements[
'fileName']),null,
"pStyle");
602 $cell3 = $table->addCell($thirdColLen);
603 asort($statements[
"licenses"]);
604 foreach ($statements[
'licenses'] as $licenseName) {
605 $cell3->addText(htmlspecialchars($licenseName), $this->filePathColumn,
"pStyle");
609 $table->addRow($this->rowHeight);
610 $table->addCell($firstColLen,
"pStyle")->addText(
"");
611 $table->addCell($secondColLen,
"pStyle")->addText(
"");
612 $table->addCell($thirdColLen,
"pStyle")->addText(
"");
614 $section->addTextBreak();
626 $secondColLen = 2000;
629 $section->addTitle(htmlspecialchars(
"Results of License Scan"), 2);
630 $section->addText($titleSubHeading, $this->subHeadingStyle);
632 $table = $section->addTable($this->tablestyle);
634 foreach ($dataHistogram as $licenseData) {
635 $table->addRow($this->rowHeight);
636 $table->addCell($firstColLen)->addText($licenseData[
'scannerCount'],
"pStyle");
637 $table->addCell($secondColLen)->addText($licenseData[
'editedCount'],
"pStyle");
638 $table->addCell($thirdColLen)->addText(htmlspecialchars($licenseData[
'licenseShortname']),
"pStyle");
640 $section->addTextBreak();
659 $userName = $this->userDao->getUserName(
$userId);
660 $groupName = $this->userDao->getGroupNameById(
$groupId);
661 $packageName = $this->uploadDao->getUpload($uploadId)->getFilename();
663 $packageName = str_replace(
'(',
'_',$packageName);
664 $packageName = str_replace(
' ',
'_',$packageName);
665 $packageName = str_replace(
')',
'_',$packageName);
667 $parentItem = $this->uploadDao->getParentItemBounds($uploadId);
668 $docLayout = array(
"orientation" =>
"landscape",
669 "marginLeft" =>
"950",
670 "marginRight" =>
"950",
671 "marginTop" =>
"950",
672 "marginBottom" =>
"950" 676 $phpWord =
new PhpWord();
679 $jobInfo = $this->
dbManager->getSingleRow(
"SELECT extract(epoch from jq_starttime) " 680 .
" AS ts, jq_cmd_args FROM jobqueue WHERE jq_job_fk=$1", array($this->
jobId));
681 $timestamp = $jobInfo[
'ts'];
683 if (!empty($jobInfo[
'jq_cmd_args'])) {
684 $packageUri =
trim($jobInfo[
'jq_cmd_args']).
"?mod=showjobs&upload=".$uploadId;
691 $section = $phpWord->addSection($docLayout);
696 list($obligations, $whiteLists) = $this->obligationsGetter->getObligations($contents[
'licenses'][
'statements'],
697 $contents[
'licensesMain'][
'statements'], $uploadId,
$groupId);
700 $reportStaticSection->reportHeader($section);
702 list($contents[
'licensesMain'][
'statements'], $contents[
'licenses'][
'statements']) = $this->licenseClearedGetter->updateIdentifiedGlobalLicenses($contents[
'licensesMain'][
'statements'], $contents[
'licenses'][
'statements']);
705 $reportSummarySection->summaryTable($section, $uploadId, $userName,
706 $contents[
'licensesMain'][
'statements'], $contents[
'licenses'][
'statements'],
707 $contents[
'licensesHist'][
'statements'], $contents[
'otherStatement'], $timestamp, $groupName, $packageUri);
710 $bookMarkCell = $reportStaticSection->assessmentSummaryTable($section, $contents[
'otherStatement']);
713 $reportStaticSection->todoTable($section);
716 $reportStaticSection->todoObliTable($section, $obligations);
719 $heading =
"Acknowledgements";
720 $titleSubHeadingAcknowledgement =
"(Reference to the license, Text of acknowledgements, File path)";
721 $this->
bulkLicenseTable($section, $heading, $contents[
'licenseAcknowledgements'][
'statements'], $titleSubHeadingAcknowledgement);
724 $heading =
"Export Restrictions";
725 $titleSubHeadingCEI =
"(Statements, Comments, File path)";
726 $section->addBookmark(
"eccInternalLink");
727 $textEcc =
"The content of this paragraph is not the result of the evaluation" 728 .
" of the export control experts (the ECCN). It contains information" 729 .
" found by the scanner which shall be taken in consideration by" 730 .
" the export control experts during the evaluation process. If" 731 .
" the scanner identifies an ECCN it will be listed here. (NOTE:" 732 .
" The ECCN is seen as an attribute of the component release and" 733 .
" thus it shall be present in the component catalogue.";
734 $this->
getRowsAndColumnsForCEI($section, $heading, $contents[
'ecc'][
'statements'], $titleSubHeadingCEI, $textEcc);
738 $subHeading =
"Notes on individual files";
739 $reportStaticSection->notes($section, $heading, $subHeading);
740 $titleSubHeadingNotes =
"(License name, Comment Entered, File path)";
741 $this->
bulkLicenseTable($section,
"", $contents[
'licenseComments'][
'statements'], $titleSubHeadingNotes);
744 $titleSubHeadingHistogram =
"(Scanner count, Concluded license count, License name)";
745 $this->
licenseHistogram($section, $contents[
'licensesHist'][
'statements'], $titleSubHeadingHistogram);
748 $titleSubHeadingLicense =
"(License name, License text, File path)";
749 $this->
globalLicenseTable($section, $contents[
'licensesMain'][
'statements'], $titleSubHeadingLicense);
752 $heading =
"Other OSS Licenses (red) - specific obligations";
753 $redLicense = array(
"color" => array(
"bgColor" =>
"F9A7B0"),
"riskLevel" => array(
"5",
"4"));
754 $this->
licensesTable($section, $heading, $contents[
'licenses'][
'statements'], $redLicense, $titleSubHeadingLicense);
757 $heading =
"Other OSS Licenses (yellow) - additional obligations to common rules (e.g. copyleft)";
758 $yellowLicense = array(
"color" => array(
"bgColor" =>
"FEFF99"),
"riskLevel" => array(
"3",
"2"));
759 $this->
licensesTable($section, $heading, $contents[
'licenses'][
'statements'], $yellowLicense, $titleSubHeadingLicense);
762 $heading =
"Other OSS Licenses (white) - only common rules";
763 $whiteLicense = array(
"color" => array(
"bgColor" =>
"FFFFFF"),
"riskLevel" => array(
"",
"0",
"1"));
764 $this->
licensesTable($section, $heading, $contents[
'licenses'][
'statements'], $whiteLicense, $titleSubHeadingLicense);
766 $heading =
"Overview of All Licenses with or without Obligations";
767 $titleSubHeadingObli =
"(License ShortName, Obligation)";
768 $reportStaticSection->allLicensesWithAndWithoutObligations($section, $heading, $obligations, $whiteLists, $titleSubHeadingObli);
771 $heading =
"Copyrights";
772 $this->
getRowsAndColumnsForCEI($section, $heading, $contents[
'copyrights'][
'scannerFindings'], $titleSubHeadingCEI);
775 $heading =
"Copyrights (User Findings)";
776 $this->
getRowsAndColumnsForCEI($section, $heading, $contents[
'copyrights'][
'userFindings'], $titleSubHeadingCEI);
779 $heading =
"Bulk Findings";
780 $this->
bulkLicenseTable($section, $heading, $contents[
'bulkLicenses'][
'statements'], $titleSubHeadingLicense);
783 $heading =
"Non-Functional Licenses";
784 $reportStaticSection->getNonFunctionalLicenses($section, $heading);
787 $heading =
"Irrelevant Files";
788 $titleSubHeadingIrre =
"(Path, Files, Licenses)";
792 $subHeading =
"Comment for Irrelevant files";
793 $section->addTitle(htmlspecialchars(
"$subHeading"), 3);
794 $titleSubHeadingNotes =
"(License name, Comment Entered, File path)";
795 $this->
bulkLicenseTable($section,
"", $contents[
'licensesIrreComment'][
'statements'], $titleSubHeadingNotes);
798 $heading =
"Do not use Files";
799 if ($contents[
'otherStatement'][
'includeDNU']) {
801 $columnStyleWithUnderline = array(
"size" => 11,
"color" =>
"0000A0",
'underline' =>
'single');
802 $section->addBookmark(
'DNUBookmark');
803 $bookMarkCell->addLink(
'DNUBookmark', htmlspecialchars(
' NOTE: DO NOT USE files found! Please check Do not use files section', ENT_COMPAT,
'UTF-8'), $columnStyleWithUnderline,
"pStyle",
true);
805 $titleSubHeadingIrre =
"(Path, Files, Licenses)";
809 $subHeading =
"Comment for Do not use files";
810 $section->addTitle(htmlspecialchars(
"$subHeading"), 3);
811 $titleSubHeadingNotes =
"(License name, Comment Entered, File path)";
812 $this->
bulkLicenseTable($section,
"", $contents[
'licensesDNUComment'][
'statements'], $titleSubHeadingNotes);
815 $reportStaticSection->clearingProtocolChangeLogTable($section);
818 $reportStaticSection->reportFooter($phpWord, $section, $contents[
'otherStatement']);
820 $fileBase = $SysConf[
"FOSSOLOGY"][
"path"].
"/report/";
821 if (!is_dir($fileBase)) {
822 mkdir($fileBase, 0777,
true);
825 $fileName = $fileBase.
"$packageName".
"_clearing_report_".date(
"D_M_d_m_Y_h_i_s").
".docx";
826 $objWriter = IOFactory::createWriter($phpWord,
"Word2007");
827 $objWriter->save($fileName);
841 $this->
dbManager->getSingleRow(
"INSERT INTO reportgen(upload_fk, job_fk, filepath) VALUES($1,$2,$3)",
842 array($uploadId,
$jobId, $filename), __METHOD__);
847 $agent->scheduler_connect();
848 $agent->run_scheduler_event_loop();
849 $agent->scheduler_disconnect(0);
heartbeat($newProcessed)
Send hear beat to the scheduler.
$licenseIrrelevantCommentGetter
writeReport($contents, $uploadId, $groupId, $userId)
Writes the report to a file.
processUploadId($uploadId)
Given an upload ID, process the items in it.
Structure of an Agent with all required parameters.
int jobId
The id of the job.
bulkLicenseTable(Section $section, $title, $licenses, $titleSubHeading)
This function lists out the bulk licenses, comments of identified licenses.
Handles static part of report.
getRowsAndColumnsForCEI(Section $section, $title, $statementsCEI, $titleSubHeading, $text="")
Copyright or ecc table.
documentSettingsAndStyles(PhpWord &$phpWord, $timestamp, $userName)
Setting default heading styles and paragraph styles.
getRowsAndColumnsForIrre(Section $section, $title, $licensesIrre, $titleSubHeading)
Irrelevant files in report.
fo_dbManager * dbManager
fo_dbManager object
licenseHistogram(Section $section, $dataHistogram, $titleSubHeading)
License histogram into report.
globalLicenseTable(Section $section, $mainLicenses, $titleSubHeading)
Generate global license table.
Generates unified report.
licensesTable(Section $section, $title, $licenses, $riskarray, $titleSubHeading)
This function lists out the red, white & yellow licenses.
updateReportTable($uploadId, $jobId, $filename)
Update database with generated report path.
char * trim(char *ptext)
Trimming whitespace.