diff --git a/app/Database.php b/app/Database.php index 56a99fb0..a7a96804 100644 --- a/app/Database.php +++ b/app/Database.php @@ -39,6 +39,7 @@ class Database extends Model 'security_need_i', 'security_need_a', 'security_need_t', + 'security_need_auth', 'external', 'created_at', 'updated_at', diff --git a/app/Http/Controllers/Admin/CartographyController.php b/app/Http/Controllers/Admin/CartographyController.php index 235c83e0..d7ea7967 100644 --- a/app/Http/Controllers/Admin/CartographyController.php +++ b/app/Http/Controllers/Admin/CartographyController.php @@ -373,6 +373,17 @@ public function cartography(Request $request) trans('global.tracability') . ' : ' . ([1 => trans('global.low'),2 => trans('global.medium'),3 => trans('global.strong'),4 => trans('global.very_strong')][$macroProcess->security_need_t] ?? '') . + ( + config('mercator-config.parameters.security_need_auth') ? + ( + '
' . + trans('global.authenticity') . + ' : ' . + ([1 => trans('global.low'),2 => trans('global.medium'),3 => trans('global.strong'),4 => trans('global.very_strong')][$macroProcess->security_need_auth] ?? '') + ) + : + "" + ) . '

' ); //--- @@ -442,6 +453,17 @@ public function cartography(Request $request) trans('global.tracability') . ' : ' . ([1 => trans('global.low'),2 => trans('global.medium'),3 => trans('global.strong'),4 => trans('global.very_strong')][$process->security_need_t] ?? '') . + ( + config('mercator-config.parameters.security_need_auth') ? + ( + '
' . + trans('global.authenticity') . + ' : ' . + ([1 => trans('global.low'),2 => trans('global.medium'),3 => trans('global.strong'),4 => trans('global.very_strong')][$process->security_need_auth] ?? '') + ) + : + "" + ) . '

' ); // Owner @@ -594,6 +616,17 @@ public function cartography(Request $request) trans('global.tracability') . ' : ' . ([1 => trans('global.low'),2 => trans('global.medium'),3 => trans('global.strong'),4 => trans('global.very_strong')][$information->security_need_t] ?? '') . + ( + config('mercator-config.parameters.security_need_auth') ? + ( + '
' . + trans('global.authenticity') . + ' : ' . + ([1 => trans('global.low'),2 => trans('global.medium'),3 => trans('global.strong'),4 => trans('global.very_strong')][$information->security_need_auth] ?? '') + ) + : + "" + ) . '

' ); @@ -762,6 +795,17 @@ public function cartography(Request $request) trans('global.tracability') . ' : ' . ([1 => trans('global.low'),2 => trans('global.medium'),3 => trans('global.strong'),4 => trans('global.very_strong')][$application->security_need_t] ?? '') . + ( + config('mercator-config.parameters.security_need_auth') ? + ( + '
' . + trans('global.authenticity') . + ' : ' . + ([1 => trans('global.low'),2 => trans('global.medium'),3 => trans('global.strong'),4 => trans('global.very_strong')][$application->security_need_auth] ?? '') + ) + : + "" + ) . '

' ); @@ -1011,6 +1055,17 @@ public function cartography(Request $request) trans('global.tracability') . ' : ' . ([1 => trans('global.low'),2 => trans('global.medium'),3 => trans('global.strong'),4 => trans('global.very_strong')][$database->security_need_t] ?? '') . + ( + config('mercator-config.parameters.security_need_auth') ? + ( + '
' . + trans('global.authenticity') . + ' : ' . + ([1 => trans('global.low'),2 => trans('global.medium'),3 => trans('global.strong'),4 => trans('global.very_strong')][$database->security_need_auth] ?? '') + ) + : + "" + ) . '

' ); @@ -1394,6 +1449,17 @@ public function cartography(Request $request) trans('global.tracability') . ' : ' . ([1 => trans('global.low'),2 => trans('global.medium'),3 => trans('global.strong'),4 => trans('global.very_strong')][$network->security_need_t] ?? '') . + ( + config('mercator-config.parameters.security_need_auth') ? + ( + '
' . + trans('global.authenticity') . + ' : ' . + ([1 => trans('global.low'),2 => trans('global.medium'),3 => trans('global.strong'),4 => trans('global.very_strong')][$network->security_need_auth] ?? '') + ) + : + "" + ) . '

' ); //---- diff --git a/app/Http/Controllers/Admin/ConfigurationController.php b/app/Http/Controllers/Admin/ConfigurationController.php index 8a67533f..fded5196 100644 --- a/app/Http/Controllers/Admin/ConfigurationController.php +++ b/app/Http/Controllers/Admin/ConfigurationController.php @@ -256,4 +256,48 @@ public function saveCVEConfig(Request $request) ) ->withErrors($msg); } + + /* + * Return the parameters + */ + public function getParameters() + { + abort_if(Gate::denies('configure'), Response::HTTP_FORBIDDEN, '403 Forbidden'); + + // Get configuration + $security_need_auth = config('mercator-config.parameters.security_need_auth'); + + // Return + return view( + 'admin.config.parameters', + compact('security_need_auth') + ); + } + + /* + * Save the parameters + */ + public function saveParameters(Request $request) + { + abort_if(Gate::denies('configure'), Response::HTTP_FORBIDDEN, '403 Forbidden'); + + // read request + $security_need_auth = request('security_need_auth'); + + // Save parameters + config(['mercator-config.parameters.security_need_auth' => $security_need_auth]); + + // Save configuration + $text = 'withErrors('Configuration saved !'); + } + + } diff --git a/app/Http/Controllers/Admin/ReportController.php b/app/Http/Controllers/Admin/ReportController.php index c13fa34f..ca02f608 100644 --- a/app/Http/Controllers/Admin/ReportController.php +++ b/app/Http/Controllers/Admin/ReportController.php @@ -1766,8 +1766,6 @@ public function administration() public function entities() { - $path = storage_path('app/entities-'. Carbon::today()->format('Ymd') .'.ods'); - $entities = Entity::All()->sortBy('name'); $header = [ @@ -1820,7 +1818,12 @@ public function entities() $row++; } - $writer = new \PhpOffice\PhpSpreadsheet\Writer\Ods($spreadsheet); + //$writer = new \PhpOffice\PhpSpreadsheet\Writer\Ods($spreadsheet); + $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet); + + // $path = storage_path('app/entities-'. Carbon::today()->format('Ymd') .'.ods'); + $path = storage_path('app/entities-'. Carbon::today()->format('Ymd') .'.xlsx'); + $writer->save($path); return response()->download($path); @@ -1962,6 +1965,7 @@ public function activityReport() // Saving the document as Word2007 file. $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); + $objWriter->save($filepath); // return @@ -1970,8 +1974,6 @@ public function activityReport() public function activityList() { - $path = storage_path('app/register-'. Carbon::today()->format('Ymd') .'.ods'); - $register = DataProcessing::All()->sortBy('name'); $header = [ @@ -2082,7 +2084,12 @@ public function activityList() $row++; } - $writer = new \PhpOffice\PhpSpreadsheet\Writer\Ods($spreadsheet); + //$writer = new \PhpOffice\PhpSpreadsheet\Writer\Ods($spreadsheet); + $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet); + + // $path = storage_path('app/register-'. Carbon::today()->format('Ymd') .'.ods'); + $path = storage_path('app/register-'. Carbon::today()->format('Ymd') .'.xlsx'); + $writer->save($path); return response()->download($path); @@ -2090,8 +2097,6 @@ public function activityList() public function applicationsByBlocks() { - $path = storage_path('app/applications-'. Carbon::today()->format('Ymd') .'.ods'); - $applicationBlocks = ApplicationBlock::All()->sortBy('name'); $applicationBlocks->load('applications'); @@ -2112,7 +2117,13 @@ public function applicationsByBlocks() trans('global.confidentiality_short'), trans('global.integrity_short'), trans('global.availability_short'), - trans('global.tracability_short'), + trans('global.tracability_short') + ]; + if (config('mercator-config.parameters.security_need_auth')) { + array_push($header, + trans('global.authenticity_short')); + } + array_push($header, trans('cruds.application.fields.RTO'), trans('cruds.application.fields.RPO'), trans('cruds.application.fields.documentation'), @@ -2120,43 +2131,48 @@ public function applicationsByBlocks() trans('cruds.physicalServer.title'), trans('cruds.workstation.title'), trans('cruds.database.title'), - ]; + ); $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); $sheet->fromArray([$header], null, 'A1'); - $sheet->getColumnDimension('A')->setAutoSize(true); // block - $sheet->getColumnDimension('B')->setAutoSize(true); // name - $sheet->getColumnDimension('C')->setWidth(60, 'pt'); // description - $sheet->getColumnDimension('D')->setAutoSize(true); // CPE - $sheet->getColumnDimension('E')->setAutoSize(true); // entity_resp - $sheet->getColumnDimension('F')->setAutoSize(true); // entities - $sheet->getColumnDimension('G')->setAutoSize(true); // resp - $sheet->getColumnDimension('H')->setWidth(60, 'pt'); // process - $sheet->getColumnDimension('I')->setAutoSize(true); // editor - $sheet->getColumnDimension('J')->setAutoSize(true); // tech - $sheet->getColumnDimension('K')->setAutoSize(true); // type - $sheet->getColumnDimension('L')->setAutoSize(true); // users - $sheet->getColumnDimension('M')->setAutoSize(true); // external + $col = 'A'; + $sheet->getColumnDimension(self::col($i++))->setAutoSize(true); // block + $sheet->getColumnDimension(self::col($i++))->setAutoSize(true); // name + $sheet->getColumnDimension(self::col($i++))->setWidth(60, 'pt'); // description + $sheet->getColumnDimension(self::col($i++))->setAutoSize(true); // CPE + $sheet->getColumnDimension(self::col($i++))->setAutoSize(true); // entity_resp + $sheet->getColumnDimension(self::col($i++))->setAutoSize(true); // entities + $sheet->getColumnDimension(self::col($i++))->setAutoSize(true); // resp + $sheet->getColumnDimension(self::col($i++))->setWidth(60, 'pt'); // process + $sheet->getColumnDimension(self::col($i++))->setAutoSize(true); // editor + $sheet->getColumnDimension(self::col($i++))->setAutoSize(true); // tech + $sheet->getColumnDimension(self::col($i++))->setAutoSize(true); // type + $sheet->getColumnDimension(self::col($i++))->setAutoSize(true); // users + $sheet->getColumnDimension(self::col($i++))->setAutoSize(true); // external // CIAT - $sheet->getColumnDimension('N')->setWidth(10, 'pt'); - $sheet->getStyle('N')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); - $sheet->getColumnDimension('O')->setWidth(10, 'pt'); - $sheet->getStyle('O')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); - $sheet->getColumnDimension('P')->setWidth(10, 'pt'); - $sheet->getStyle('P')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); - $sheet->getColumnDimension('Q')->setWidth(10, 'pt'); - $sheet->getStyle('Q')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $sheet->getColumnDimension($col)->setWidth(10, 'pt'); + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $sheet->getColumnDimension($col)->setWidth(10, 'pt'); + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $sheet->getColumnDimension($col)->setWidth(10, 'pt'); + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $sheet->getColumnDimension($col)->setWidth(10, 'pt'); + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + if (config('mercator-config.parameters.security_need_auth')) { + $sheet->getColumnDimension($col)->setWidth(10, 'pt'); + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + } // RTO - RPO - $sheet->getColumnDimension('R')->setAutoSize(true); - $sheet->getColumnDimension('S')->setAutoSize(true); + $sheet->getColumnDimension(self::col($i++))->setAutoSize(true); + $sheet->getColumnDimension(self::col($i++))->setAutoSize(true); - $sheet->getColumnDimension('T')->setAutoSize(true); - $sheet->getColumnDimension('U')->setWidth(200, 'pt'); // logical servers - $sheet->getColumnDimension('V')->setWidth(200, 'pt'); // physical serveurs - $sheet->getColumnDimension('W')->setWidth(200, 'pt'); // workstations - $sheet->getColumnDimension('X')->setWidth(200, 'pt'); // databases + $sheet->getColumnDimension(self::col($i++))->setAutoSize(true); + $sheet->getColumnDimension(self::col($i++))->setWidth(200, 'pt'); // logical servers + $sheet->getColumnDimension(self::col($i++))->setWidth(200, 'pt'); // physical serveurs + $sheet->getColumnDimension(self::col($i++))->setWidth(200, 'pt'); // workstations + $sheet->getColumnDimension(self::col($i++))->setWidth(200, 'pt'); // databases // bold title $sheet->getStyle('1')->getFont()->setBold(true); @@ -2168,37 +2184,43 @@ public function applicationsByBlocks() $row = 2; foreach ($applicationBlocks as $applicationBlock) { foreach ($applicationBlock->applications as $application) { - $sheet->setCellValue("A{$row}", $applicationBlock->name); - $sheet->setCellValue("B{$row}", $application->name); - $sheet->setCellValue("C{$row}", $html->toRichTextObject($application->description)); - $sheet->setCellValue("D{$row}", $application->vendor . ':' . $application->product . ':' . $application->version); - $sheet->setCellValue("E{$row}", $application->entity_resp ? $application->entity_resp->name : ''); - $sheet->setCellValue("F{$row}", $application->entities->implode('name', ', ')); - $sheet->setCellValue("G{$row}", $application->responsible); - $sheet->setCellValue("H{$row}", $application->processes->implode('name', ', ')); - $sheet->setCellValue("I{$row}", $application->editor); - $sheet->setCellValue("J{$row}", $application->technology); - $sheet->setCellValue("K{$row}", $application->type); - $sheet->setCellValue("L{$row}", $application->users); - $sheet->setCellValue("M{$row}", $application->external); - - $sheet->setCellValue("N{$row}", $application->security_need_c); - $this->addSecurityNeedColor($sheet, "N{$row}", $application->security_need_c); - - $sheet->setCellValue("O{$row}", $application->security_need_i); - $this->addSecurityNeedColor($sheet, "O{$row}", $application->security_need_i); - - $sheet->setCellValue("P{$row}", $application->security_need_a); - $this->addSecurityNeedColor($sheet, "P{$row}", $application->security_need_a); - - $sheet->setCellValue("Q{$row}", $application->security_need_t); - $this->addSecurityNeedColor($sheet, "Q{$row}", $application->security_need_t); - - $sheet->setCellValue("R{$row}", $application->rto); - $sheet->setCellValue("S{$row}", $application->rpo); - - $sheet->setCellValue("T{$row}", $application->documentation); - $sheet->setCellValue("U{$row}", $application->logical_servers->implode('name', ', ')); + $col = 'A'; + $sheet->setCellValue(self::col($i++) . $row, $applicationBlock->name); + $sheet->setCellValue(self::col($i++) . $row, $application->name); + $sheet->setCellValue(self::col($i++) . $row, $html->toRichTextObject($application->description)); + $sheet->setCellValue(self::col($i++) . $row, $application->vendor . ':' . $application->product . ':' . $application->version); + $sheet->setCellValue(self::col($i++) . $row, $application->entity_resp ? $application->entity_resp->name : ''); + $sheet->setCellValue(self::col($i++) . $row, $application->entities->implode('name', ', ')); + $sheet->setCellValue(self::col($i++) . $row, $application->responsible); + $sheet->setCellValue(self::col($i++) . $row, $application->processes->implode('name', ', ')); + $sheet->setCellValue(self::col($i++) . $row, $application->editor); + $sheet->setCellValue(self::col($i++) . $row, $application->technology); + $sheet->setCellValue(self::col($i++) . $row, $application->type); + $sheet->setCellValue(self::col($i++) . $row, $application->users); + $sheet->setCellValue(self::col($i++) . $row, $application->external); + + $sheet->setCellValue($col . $row, $application->security_need_c); + $this->addSecurityNeedColor($sheet, self::col($i++) . $row, $application->security_need_c); + + $sheet->setCellValue($col . $row, $application->security_need_i); + $this->addSecurityNeedColor($sheet, self::col($i++) . $row, $application->security_need_i); + + $sheet->setCellValue($col . $row, $application->security_need_a); + $this->addSecurityNeedColor($sheet, self::col($i++) . $row, $application->security_need_a); + + $sheet->setCellValue($col . $row, $application->security_need_t); + $this->addSecurityNeedColor($sheet, self::col($i++) . $row, $application->security_need_t); + + if (config('mercator-config.parameters.security_need_auth')) { + $sheet->setCellValue($col . $row, $application->security_need_auth); + $this->addSecurityNeedColor($sheet, self::col($i++) . $row, $application->security_need_auth); + } + + $sheet->setCellValue(self::col($i++) . $row, $application->rto); + $sheet->setCellValue(self::col($i++) . $row, $application->rpo); + + $sheet->setCellValue(self::col($i++) . $row, $application->documentation); + $sheet->setCellValue(self::col($i++) . $row, $application->logical_servers->implode('name', ', ')); $res = null; // Done: request improved @@ -2246,7 +2268,12 @@ public function applicationsByBlocks() } } - $writer = new \PhpOffice\PhpSpreadsheet\Writer\Ods($spreadsheet); + // $writer = new \PhpOffice\PhpSpreadsheet\Writer\Ods($spreadsheet); + $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet); + + // $path = storage_path('app/applications-'. Carbon::today()->format('Ymd') .'.ods'); + $path = storage_path('app/applications-'. Carbon::today()->format('Ymd') .'.xlsx'); + $writer->save($path); return response()->download($path); @@ -2254,8 +2281,6 @@ public function applicationsByBlocks() public function logicalServers() { - $path = storage_path('app/logicalServers-'. Carbon::today()->format('Ymd') .'.ods'); - $logicalServers = LogicalServer::All()->sortBy('name'); $logicalServers->load('applications', 'applications.application_block'); @@ -2322,17 +2347,19 @@ public function logicalServers() } } - $writer = new \PhpOffice\PhpSpreadsheet\Writer\Ods($spreadsheet); + // $writer = new \PhpOffice\PhpSpreadsheet\Writer\Ods($spreadsheet); + $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet); + + // $path = storage_path('app/logicalServers-'. Carbon::today()->format('Ymd') .'.ods'); + $path = storage_path('app/logicalServers-'. Carbon::today()->format('Ymd') .'.xlsx'); + $writer->save($path); return response()->download($path); } - // TODO : i18n public function externalAccess() { - $path = storage_path('app/externalAccess-'. Carbon::today()->format('Ymd') .'.ods'); - $accesses = ExternalConnectedEntity::All()->sortBy('name'); $accesses->load('entity', 'network'); @@ -2394,7 +2421,12 @@ public function externalAccess() $row++; } - $writer = new \PhpOffice\PhpSpreadsheet\Writer\Ods($spreadsheet); + // $writer = new \PhpOffice\PhpSpreadsheet\Writer\Ods($spreadsheet); + $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet); + + // $path = storage_path('app/externalAccess-'. Carbon::today()->format('Ymd') .'.ods'); + $path = storage_path('app/externalAccess-'. Carbon::today()->format('Ymd') .'.xlsx'); + $writer->save($path); return response()->download($path); @@ -2404,8 +2436,6 @@ public function externalAccess() public function logicalServerConfigs() { - $path = storage_path('app/logicalServers-'. Carbon::today()->format('Ymd') .'.ods'); - $logicalServers = LogicalServer::All()->sortBy('name'); $logicalServers->load('applications', 'servers'); @@ -2482,7 +2512,12 @@ public function logicalServerConfigs() $row++; } - $writer = new \PhpOffice\PhpSpreadsheet\Writer\Ods($spreadsheet); + // $writer = new \PhpOffice\PhpSpreadsheet\Writer\Ods($spreadsheet); + $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet); + + // $path = storage_path('app/logicalServers-'. Carbon::today()->format('Ymd') .'.ods'); + $path = storage_path('app/logicalServers-'. Carbon::today()->format('Ymd') .'.xslx'); + $writer->save($path); return response()->download($path); @@ -2490,93 +2525,127 @@ public function logicalServerConfigs() public function securityNeeds() { - $path = storage_path('app/securityNeeds-'. Carbon::today()->format('Ymd') .'.ods'); - // macroprocess - process - application - base de données - information - $header = [ + $header = []; + array_push($header, trans('cruds.macroProcessus.title'), trans('global.confidentiality_short'), trans('global.integrity_short'), trans('global.availability_short'), - trans('global.tracability_short'), + trans('global.tracability_short')); + if (config('mercator-config.parameters.security_need_auth')) + array_push($header, trans('global.authenticity_short')); + array_push($header, trans('cruds.process.title'), trans('global.confidentiality_short'), trans('global.integrity_short'), trans('global.availability_short'), - trans('global.tracability_short'), + trans('global.tracability_short')); + if (config('mercator-config.parameters.security_need_auth')) + array_push($header, trans('global.authenticity_short')); + array_push($header, trans('cruds.application.title'), trans('global.confidentiality_short'), trans('global.integrity_short'), trans('global.availability_short'), - trans('global.tracability_short'), + trans('global.tracability_short')); + if (config('mercator-config.parameters.security_need_auth')) + array_push($header, trans('global.authenticity_short')); + array_push($header, trans('cruds.database.title'), trans('global.confidentiality_short'), trans('global.integrity_short'), trans('global.availability_short'), - trans('global.tracability_short'), + trans('global.tracability_short')); + if (config('mercator-config.parameters.security_need_auth')) + array_push($header, trans('global.authenticity_short')); + array_push($header, trans('cruds.information.title'), trans('global.confidentiality_short'), trans('global.integrity_short'), trans('global.availability_short'), - trans('global.tracability_short'), - ]; + trans('global.tracability_short')); + if (config('mercator-config.parameters.security_need_auth')) + array_push($header, trans('global.authenticity_short')); $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); $sheet->fromArray([$header], null, 'A1'); // Widths - $sheet->getColumnDimension('A')->setAutoSize(true); - $sheet->getColumnDimension('B')->setWidth(10, 'pt'); - $sheet->getColumnDimension('C')->setWidth(10, 'pt'); - $sheet->getColumnDimension('D')->setWidth(10, 'pt'); - $sheet->getColumnDimension('E')->setWidth(10, 'pt'); - $sheet->getColumnDimension('F')->setAutoSize(true); - $sheet->getColumnDimension('G')->setWidth(10, 'pt'); - $sheet->getColumnDimension('H')->setWidth(10, 'pt'); - $sheet->getColumnDimension('I')->setWidth(10, 'pt'); - $sheet->getColumnDimension('J')->setWidth(10, 'pt'); - $sheet->getColumnDimension('K')->setAutoSize(true); - $sheet->getColumnDimension('L')->setWidth(10, 'pt'); - $sheet->getColumnDimension('M')->setWidth(10, 'pt'); - $sheet->getColumnDimension('N')->setWidth(10, 'pt'); - $sheet->getColumnDimension('O')->setWidth(10, 'pt'); - $sheet->getColumnDimension('P')->setAutoSize(true); - $sheet->getColumnDimension('Q')->setWidth(10, 'pt'); - $sheet->getColumnDimension('R')->setWidth(10, 'pt'); - $sheet->getColumnDimension('S')->setWidth(10, 'pt'); - $sheet->getColumnDimension('T')->setWidth(10, 'pt'); - $sheet->getColumnDimension('U')->setAutoSize(true); - $sheet->getColumnDimension('V')->setWidth(10, 'pt'); - $sheet->getColumnDimension('W')->setWidth(10, 'pt'); - $sheet->getColumnDimension('X')->setWidth(10, 'pt'); - $sheet->getColumnDimension('Y')->setWidth(10, 'pt'); + $i=0; + $sheet->getColumnDimension(self::col($i++))->setAutoSize(true); + $sheet->getColumnDimension(self::col($i++))->setWidth(12, 'pt'); + $sheet->getColumnDimension(self::col($i++))->setWidth(12, 'pt'); + $sheet->getColumnDimension(self::col($i++))->setWidth(12, 'pt'); + $sheet->getColumnDimension(self::col($i++))->setWidth(12, 'pt'); + if (config('mercator-config.parameters.security_need_auth')) + $sheet->getColumnDimension(self::col($i++))->setWidth(12, 'pt'); + $sheet->getColumnDimension(self::col($i++))->setAutoSize(true); + $sheet->getColumnDimension(self::col($i++))->setWidth(12, 'pt'); + $sheet->getColumnDimension(self::col($i++))->setWidth(12, 'pt'); + $sheet->getColumnDimension(self::col($i++))->setWidth(12, 'pt'); + $sheet->getColumnDimension(self::col($i++))->setWidth(12, 'pt'); + if (config('mercator-config.parameters.security_need_auth')) + $sheet->getColumnDimension(self::col($i++))->setWidth(12, 'pt'); + $sheet->getColumnDimension(self::col($i++))->setAutoSize(true); + $sheet->getColumnDimension(self::col($i++))->setWidth(12, 'pt'); + $sheet->getColumnDimension(self::col($i++))->setWidth(12, 'pt'); + $sheet->getColumnDimension(self::col($i++))->setWidth(12, 'pt'); + $sheet->getColumnDimension(self::col($i++))->setWidth(12, 'pt'); + if (config('mercator-config.parameters.security_need_auth')) + $sheet->getColumnDimension(self::col($i++))->setWidth(12, 'pt'); + $sheet->getColumnDimension(self::col($i++))->setAutoSize(true); + $sheet->getColumnDimension(self::col($i++))->setWidth(12, 'pt'); + $sheet->getColumnDimension(self::col($i++))->setWidth(12, 'pt'); + $sheet->getColumnDimension(self::col($i++))->setWidth(12, 'pt'); + $sheet->getColumnDimension(self::col($i++))->setWidth(12, 'pt'); + if (config('mercator-config.parameters.security_need_auth')) + $sheet->getColumnDimension(self::col($i++))->setWidth(12, 'pt'); + $sheet->getColumnDimension(self::col($i++))->setAutoSize(true); + $sheet->getColumnDimension(self::col($i++))->setWidth(12, 'pt'); + $sheet->getColumnDimension(self::col($i++))->setWidth(12, 'pt'); + $sheet->getColumnDimension(self::col($i++))->setWidth(12, 'pt'); + $sheet->getColumnDimension(self::col($i++))->setWidth(12, 'pt'); + if (config('mercator-config.parameters.security_need_auth')) + $sheet->getColumnDimension(self::col($i++))->setWidth(12, 'pt'); // Center - $sheet->getStyle('B')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); - $sheet->getStyle('C')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); - $sheet->getStyle('D')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); - $sheet->getStyle('E')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); - - $sheet->getStyle('G')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); - $sheet->getStyle('H')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); - $sheet->getStyle('I')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); - $sheet->getStyle('J')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); - - $sheet->getStyle('L')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); - $sheet->getStyle('M')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); - $sheet->getStyle('N')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); - $sheet->getStyle('O')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); - - $sheet->getStyle('Q')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); - $sheet->getStyle('R')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); - $sheet->getStyle('S')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); - $sheet->getStyle('T')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); - - $sheet->getStyle('V')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); - $sheet->getStyle('W')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); - $sheet->getStyle('X')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); - $sheet->getStyle('Y')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $i=1; + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + if (config('mercator-config.parameters.security_need_auth')) + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $i++; + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + if (config('mercator-config.parameters.security_need_auth')) + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $i++; + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + if (config('mercator-config.parameters.security_need_auth')) + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $i++; + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + if (config('mercator-config.parameters.security_need_auth')) + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $i++; + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + if (config('mercator-config.parameters.security_need_auth')) + $sheet->getStyle(self::col($i++))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); // bold title $sheet->getStyle('1')->getFont()->setBold(true); @@ -2618,7 +2687,12 @@ public function securityNeeds() } } } - $writer = new \PhpOffice\PhpSpreadsheet\Writer\Ods($spreadsheet); + // $writer = new \PhpOffice\PhpSpreadsheet\Writer\Ods($spreadsheet); + $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet); + + // $path = storage_path('app/securityNeeds-'. Carbon::today()->format('Ymd') .'.ods'); + $path = storage_path('app/securityNeeds-'. Carbon::today()->format('Ymd') .'.xslx'); + $writer->save($path); return response()->download($path); @@ -2626,7 +2700,6 @@ public function securityNeeds() public function physicalInventory() { - $path = storage_path('app/physicalInventory-'. Carbon::today()->format('Ymd') .'.ods'); $inventory = []; @@ -2693,7 +2766,12 @@ public function physicalInventory() $row++; } - $writer = new \PhpOffice\PhpSpreadsheet\Writer\Ods($spreadsheet); + // $writer = new \PhpOffice\PhpSpreadsheet\Writer\Ods($spreadsheet); + $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet); + + // $path = storage_path('app/physicalInventory-'. Carbon::today()->format('Ymd') .'.ods'); + $path = storage_path('app/physicalInventory-'. Carbon::today()->format('Ymd') .'.xlsx'); + $writer->save($path); return response()->download($path); @@ -2701,8 +2779,6 @@ public function physicalInventory() public function workstations() { - $path = storage_path('app/physicalInventory-'. Carbon::today()->format('Ymd') .'.ods'); - $workstations = Workstation::All()->sortBy('name'); $workstations->load('applications', 'site', 'building'); @@ -2772,7 +2848,12 @@ public function workstations() $row++; } - $writer = new \PhpOffice\PhpSpreadsheet\Writer\Ods($spreadsheet); + // $writer = new \PhpOffice\PhpSpreadsheet\Writer\Ods($spreadsheet); + $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet); + + // $path = storage_path('app/physicalInventory-'. Carbon::today()->format('Ymd') .'.ods'); + $path = storage_path('app/physicalInventory-'. Carbon::today()->format('Ymd') .'.xslx'); + $writer->save($path); return response()->download($path); @@ -2780,8 +2861,6 @@ public function workstations() public function vlans() { - $path = storage_path('app/vlans-'. Carbon::today()->format('Ymd') .'.ods'); - $vlans = Vlan::orderBy('Name')->get(); $vlans->load('subnetworks'); @@ -2909,7 +2988,12 @@ public function vlans() $row++; } - $writer = new \PhpOffice\PhpSpreadsheet\Writer\Ods($spreadsheet); + //$writer = new \PhpOffice\PhpSpreadsheet\Writer\Ods($spreadsheet); + $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet); + + // $path = storage_path('app/vlans-'. Carbon::today()->format('Ymd') .'.ods'); + $path = storage_path('app/vlans-'. Carbon::today()->format('Ymd') .'.xslx'); + $writer->save($path); return response()->download($path); @@ -2926,8 +3010,6 @@ public function cve() { Log::debug('CVEReport - Start'); - $path = storage_path('app/cve-'. Carbon::today()->format('Ymd') .'.ods'); - // loop on applications $applications = DB::table('m_applications') ->select('name', 'vendor', 'product', 'version') @@ -3036,7 +3118,12 @@ public function cve() usleep(200); } - $writer = new \PhpOffice\PhpSpreadsheet\Writer\Ods($spreadsheet); + // $writer = new \PhpOffice\PhpSpreadsheet\Writer\Ods($spreadsheet); + $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet); + + // $path = storage_path('app/cve-'. Carbon::today()->format('Ymd') .'.ods'); + $path = storage_path('app/cve-'. Carbon::today()->format('Ymd') .'.xlsx'); + $writer->save($path); Log::debug('CVEReport - Done.'); @@ -3304,77 +3391,121 @@ private function addLine( ?Information $information = null ) { // Macroprocessus - $sheet->setCellValue("A{$row}", $macroprocess->name); + $i=0; + $sheet->setCellValue(self::col($i++). $row, $macroprocess->name); - $sheet->setCellValue("B{$row}", $macroprocess->security_need_c >= 0 ? $macroprocess->security_need_c : ''); - $this->addSecurityNeedColor($sheet, "B{$row}", $macroprocess->security_need_c); + $sheet->setCellValue(self::col($i). $row, $macroprocess->security_need_c >= 0 ? $macroprocess->security_need_c : ''); + $this->addSecurityNeedColor($sheet, self::col($i++). $row, $macroprocess->security_need_c); - $sheet->setCellValue("C{$row}", $macroprocess->security_need_i >= 0 ? $macroprocess->security_need_i : ''); - $this->addSecurityNeedColor($sheet, "C{$row}", $macroprocess->security_need_i); + $sheet->setCellValue(self::col($i). $row, $macroprocess->security_need_i >= 0 ? $macroprocess->security_need_i : ''); + $this->addSecurityNeedColor($sheet, self::col($i++). $row, $macroprocess->security_need_i); - $sheet->setCellValue("D{$row}", $macroprocess->security_need_a >= 0 ? $macroprocess->security_need_a : ''); - $this->addSecurityNeedColor($sheet, "D{$row}", $macroprocess->security_need_a); + $sheet->setCellValue(self::col($i). $row, $macroprocess->security_need_a >= 0 ? $macroprocess->security_need_a : ''); + $this->addSecurityNeedColor($sheet, self::col($i++). $row, $macroprocess->security_need_a); - $sheet->setCellValue("E{$row}", $macroprocess->security_need_t >= 0 ? $macroprocess->security_need_t : ''); - $this->addSecurityNeedColor($sheet, "E{$row}", $macroprocess->security_need_t); + $sheet->setCellValue(self::col($i). $row, $macroprocess->security_need_t >= 0 ? $macroprocess->security_need_t : ''); + $this->addSecurityNeedColor($sheet, self::col($i++). $row, $macroprocess->security_need_t); + + if (config('mercator-config.parameters.security_need_auth')) { + $sheet->setCellValue(self::col($i). $row, $macroprocess->security_need_auth >= 0 ? $macroprocess->security_need_auth : ''); + $this->addSecurityNeedColor($sheet, self::col($i++). $row, $macroprocess->security_need_auth); + } if ($process !== null) { // Processus - $sheet->setCellValue("F{$row}", $process->name); - $sheet->setCellValue("G{$row}", $process->security_need_c >= 0 ? $process->security_need_c : ''); - $this->addSecurityNeedColor($sheet, "G{$row}", $process->security_need_c); + $sheet->setCellValue(self::col($i++). $row, $process->name); - $sheet->setCellValue("H{$row}", $process->security_need_i >= 0 ? $process->security_need_i : ''); - $this->addSecurityNeedColor($sheet, "H{$row}", $process->security_need_i); + $sheet->setCellValue(self::col($i). $row, $process->security_need_c >= 0 ? $process->security_need_c : ''); + $this->addSecurityNeedColor($sheet, self::col($i++). $row, $process->security_need_c); - $sheet->setCellValue("I{$row}", $process->security_need_a >= 0 ? $process->security_need_a : ''); - $this->addSecurityNeedColor($sheet, "I{$row}", $process->security_need_a); + $sheet->setCellValue(self::col($i). $row, $process->security_need_i >= 0 ? $process->security_need_i : ''); + $this->addSecurityNeedColor($sheet, self::col($i++). $row, $process->security_need_i); - $sheet->setCellValue("J{$row}", $process->security_need_t >= 0 ? $process->security_need_t : ''); - $this->addSecurityNeedColor($sheet, "J{$row}", $process->security_need_t); + $sheet->setCellValue(self::col($i). $row, $process->security_need_a >= 0 ? $process->security_need_a : ''); + $this->addSecurityNeedColor($sheet, self::col($i++). $row, $process->security_need_a); + + $sheet->setCellValue(self::col($i). $row, $process->security_need_t >= 0 ? $process->security_need_t : ''); + $this->addSecurityNeedColor($sheet, self::col($i++). $row, $process->security_need_t); + + if (config('mercator-config.parameters.security_need_auth')) { + $sheet->setCellValue(self::col($i). $row, $process->security_need_auth >= 0 ? $process->security_need_auth : ''); + $this->addSecurityNeedColor($sheet, self::col($i++). $row, $process->security_need_auth); + } if ($application !== null) { // Application - $sheet->setCellValue("K{$row}", $application->name); + $sheet->setCellValue(self::col($i++). $row, $application->name); + + $sheet->setCellValue(self::col($i). $row, $application->security_need_c >= 0 ? $application->security_need_c : ''); + $this->addSecurityNeedColor($sheet, self::col($i++). $row, $application->security_need_c); - $sheet->setCellValue("L{$row}", $application->security_need_c >= 0 ? $application->security_need_c : ''); - $this->addSecurityNeedColor($sheet, "L{$row}", $application->security_need_c); + $sheet->setCellValue(self::col($i). $row, $application->security_need_i >= 0 ? $application->security_need_i : ''); + $this->addSecurityNeedColor($sheet, self::col($i++). $row, $application->security_need_i); - $sheet->setCellValue("M{$row}", $application->security_need_i >= 0 ? $application->security_need_i : ''); - $this->addSecurityNeedColor($sheet, "M{$row}", $application->security_need_i); + $sheet->setCellValue(self::col($i). $row, $application->security_need_a >= 0 ? $application->security_need_a : ''); + $this->addSecurityNeedColor($sheet, self::col($i++). $row, $application->security_need_a); - $sheet->setCellValue("N{$row}", $application->security_need_a >= 0 ? $application->security_need_a : ''); - $this->addSecurityNeedColor($sheet, "N{$row}", $application->security_need_a); + $sheet->setCellValue(self::col($i). $row, $application->security_need_t >= 0 ? $application->security_need_t : ''); + $this->addSecurityNeedColor($sheet, self::col($i++). $row, $application->security_need_t); - $sheet->setCellValue("O{$row}", $application->security_need_t >= 0 ? $application->security_need_t : ''); - $this->addSecurityNeedColor($sheet, "O{$row}", $application->security_need_t); + if (config('mercator-config.parameters.security_need_auth')) { + $sheet->setCellValue(self::col($i). $row, $application->security_need_auth >= 0 ? $application->security_need_auth : ''); + $this->addSecurityNeedColor($sheet, self::col($i++). $row, $application->security_need_auth); + } if ($database !== null) { // Database - $sheet->setCellValue("P{$row}", $database->name); - $sheet->setCellValue("Q{$row}", $database->security_need_c >= 0 ? $database->security_need_c : ''); - $this->addSecurityNeedColor($sheet, "Q{$row}", $database->security_need_c); - $sheet->setCellValue("R{$row}", $database->security_need_i >= 0 ? $database->security_need_i : ''); - $this->addSecurityNeedColor($sheet, "R{$row}", $database->security_need_i); - $sheet->setCellValue("S{$row}", $database->security_need_a >= 0 ? $database->security_need_a : ''); - $this->addSecurityNeedColor($sheet, "S{$row}", $database->security_need_a); - $sheet->setCellValue("T{$row}", $database->security_need_t >= 0 ? $database->security_need_t : ''); - $this->addSecurityNeedColor($sheet, "T{$row}", $database->security_need_t); + $sheet->setCellValue(self::col($i++). $row, $database->name); + + $sheet->setCellValue(self::col($i). $row, $database->security_need_c >= 0 ? $database->security_need_c : ''); + $this->addSecurityNeedColor($sheet, self::col($i++). $row, $database->security_need_c); + + $sheet->setCellValue(self::col($i). $row, $database->security_need_i >= 0 ? $database->security_need_i : ''); + $this->addSecurityNeedColor($sheet, self::col($i++). $row, $database->security_need_i); + + $sheet->setCellValue(self::col($i). $row, $database->security_need_a >= 0 ? $database->security_need_a : ''); + $this->addSecurityNeedColor($sheet, self::col($i++). $row, $database->security_need_a); + + $sheet->setCellValue(self::col($i). $row, $database->security_need_t >= 0 ? $database->security_need_t : ''); + $this->addSecurityNeedColor($sheet, self::col($i++). $row, $database->security_need_t); + + if (config('mercator-config.parameters.security_need_auth')) { + $sheet->setCellValue(self::col($i). $row, $database->security_need_auth >= 0 ? $database->security_need_auth : ''); + $this->addSecurityNeedColor($sheet, self::col($i++). $row, $database->security_need_auth); + } if ($information !== null) { // Information - $sheet->setCellValue("U{$row}", $information->name); - $sheet->setCellValue("V{$row}", $information->security_need_c >= 0 ? $information->security_need_c : ''); - $this->addSecurityNeedColor($sheet, "V{$row}", $information->security_need_c); - $sheet->setCellValue("W{$row}", $information->security_need_i >= 0 ? $information->security_need_i : ''); - $this->addSecurityNeedColor($sheet, "W{$row}", $information->security_need_i); - $sheet->setCellValue("X{$row}", $information->security_need_a >= 0 ? $information->security_need_a : ''); - $this->addSecurityNeedColor($sheet, "X{$row}", $information->security_need_a); - $sheet->setCellValue("Y{$row}", $information->security_need_t >= 0 ? $information->security_need_t : ''); - $this->addSecurityNeedColor($sheet, "Y{$row}", $information->security_need_t); + $sheet->setCellValue(self::col($i++). $row, $information->name); + + $sheet->setCellValue(self::col($i). $row, $information->security_need_c >= 0 ? $information->security_need_c : ''); + $this->addSecurityNeedColor($sheet, self::col($i++). $row, $information->security_need_c); + + $sheet->setCellValue(self::col($i). $row, $information->security_need_i >= 0 ? $information->security_need_i : ''); + $this->addSecurityNeedColor($sheet, self::col($i++). $row, $information->security_need_i); + + $sheet->setCellValue(self::col($i). $row, $information->security_need_a >= 0 ? $information->security_need_a : ''); + $this->addSecurityNeedColor($sheet, self::col($i++). $row, $information->security_need_a); + + $sheet->setCellValue(self::col($i). $row, $information->security_need_t >= 0 ? $information->security_need_t : ''); + $this->addSecurityNeedColor($sheet, self::col($i++). $row, $information->security_need_t); + + if (config('mercator-config.parameters.security_need_auth')) { + $sheet->setCellValue(self::col($i). $row, $information->security_need_auth >= 0 ? $information->security_need_auth : ''); + $this->addSecurityNeedColor($sheet, self::col($i++). $row, $information->security_need_auth); + } } } } } } + + // Return the Excel column index from 0 to 52 + private static function col(int $i) { + if ($i<26) + return chr(ord('A')+$i); + else + return 'A' . chr(ord('A')+($i-26)); + } + } diff --git a/app/Information.php b/app/Information.php index d79ef7a0..ddbe18c9 100644 --- a/app/Information.php +++ b/app/Information.php @@ -39,6 +39,7 @@ class Information extends Model 'security_need_i', 'security_need_a', 'security_need_t', + 'security_need_auth', 'sensitivity', 'constraints', 'created_at', diff --git a/app/MApplication.php b/app/MApplication.php index d53e3637..aba81713 100644 --- a/app/MApplication.php +++ b/app/MApplication.php @@ -53,6 +53,7 @@ class MApplication extends Model 'security_need_i', 'security_need_a', 'security_need_t', + 'security_need_auth', 'external', 'attributes', 'patching_frequency', diff --git a/app/MacroProcessus.php b/app/MacroProcessus.php index 5b8a07bc..2e35b29c 100644 --- a/app/MacroProcessus.php +++ b/app/MacroProcessus.php @@ -37,6 +37,7 @@ class MacroProcessus extends Model 'security_need_i', 'security_need_a', 'security_need_t', + 'security_need_auth', 'owner', 'created_at', 'updated_at', diff --git a/app/Network.php b/app/Network.php index e3d249c6..779767a7 100644 --- a/app/Network.php +++ b/app/Network.php @@ -40,6 +40,7 @@ class Network extends Model 'security_need_i', 'security_need_a', 'security_need_t', + 'security_need_auth', 'created_at', 'updated_at', 'deleted_at', diff --git a/app/Process.php b/app/Process.php index f3f096df..d1049d93 100644 --- a/app/Process.php +++ b/app/Process.php @@ -37,6 +37,7 @@ class Process extends Model 'security_need_i', 'security_need_a', 'security_need_t', + 'security_need_auth', 'owner', 'macroprocess_id', 'created_at', diff --git a/database/migrations/2021_05_13_180642_add_cidt_criteria.php b/database/migrations/2021_05_13_180642_add_cidt_criteria.php index 06350767..f36ba189 100644 --- a/database/migrations/2021_05_13_180642_add_cidt_criteria.php +++ b/database/migrations/2021_05_13_180642_add_cidt_criteria.php @@ -15,21 +15,14 @@ public function up() { Schema::table('macro_processuses', function (Blueprint $table) { $table->renameColumn('security_need', 'security_need_c'); - // $table->integer('security_need_i')->nullable(); - // $table->integer('security_need_a')->nullable(); - // $table->integer('security_need_t')->nullable(); }); Schema::table('macro_processuses', function (Blueprint $table) { - // $table->renameColumn('security_need', 'security_need_c'); $table->integer('security_need_i')->nullable(); $table->integer('security_need_a')->nullable(); $table->integer('security_need_t')->nullable(); }); Schema::table('processes', function (Blueprint $table) { $table->renameColumn('security_need', 'security_need_c'); - // $table->integer('security_need_i')->nullable(); - // $table->integer('security_need_a')->nullable(); - // $table->integer('security_need_t')->nullable(); }); Schema::table('processes', function (Blueprint $table) { // $table->renameColumn('security_need', 'security_need_c'); @@ -39,21 +32,14 @@ public function up() }); Schema::table('information', function (Blueprint $table) { $table->renameColumn('security_need', 'security_need_c'); - // $table->integer('security_need_i')->nullable(); - // $table->integer('security_need_a')->nullable(); - // $table->integer('security_need_t')->nullable(); }); Schema::table('information', function (Blueprint $table) { - // $table->renameColumn('security_need', 'security_need_c'); $table->integer('security_need_i')->nullable(); $table->integer('security_need_a')->nullable(); $table->integer('security_need_t')->nullable(); }); Schema::table('m_applications', function (Blueprint $table) { $table->renameColumn('security_need', 'security_need_c'); - // $table->integer('security_need_i')->nullable(); - // $table->integer('security_need_a')->nullable(); - // $table->integer('security_need_t')->nullable(); }); Schema::table('m_applications', function (Blueprint $table) { // $table->renameColumn('security_need', 'security_need_c'); @@ -63,12 +49,8 @@ public function up() }); Schema::table('databases', function (Blueprint $table) { $table->renameColumn('security_need', 'security_need_c'); - // $table->integer('security_need_i')->nullable(); - // $table->integer('security_need_a')->nullable(); - // $table->integer('security_need_t')->nullable(); }); Schema::table('databases', function (Blueprint $table) { - // $table->renameColumn('security_need', 'security_need_c'); $table->integer('security_need_i')->nullable(); $table->integer('security_need_a')->nullable(); $table->integer('security_need_t')->nullable(); @@ -103,4 +85,4 @@ public function down() $table->dropColumn(['security_need_i', 'security_need_a', 'security_need_t']); }); } -} \ No newline at end of file +} diff --git a/resources/lang/en/cruds.php b/resources/lang/en/cruds.php index 103c94aa..f7039a88 100644 --- a/resources/lang/en/cruds.php +++ b/resources/lang/en/cruds.php @@ -340,6 +340,13 @@ 'size' => 'Size', 'status' => 'Status' ], + 'parameters' => [ + 'title' => 'Paraleters', + 'title_short' => 'Parameters', + 'help' => 'This screen is used to configure optional Mercator parameters', + 'security_need_auth' => 'Authenticity', + 'security_need_auth_helper' => 'Adds the Authenticity security criterion to the existing Confidentiality, Integrity, Availability and Traceability criteria', + ], ], 'database' => [ 'description' => 'Structured and ordered set of information intended to be exploited by computer.', diff --git a/resources/lang/en/global.php b/resources/lang/en/global.php index 3d415f51..f39334b8 100644 --- a/resources/lang/en/global.php +++ b/resources/lang/en/global.php @@ -280,14 +280,16 @@ 'year' => 'Year', 'yes' => 'Yes', 'yourAccountNeedsAdminApproval' => 'Your account must be approved by the administrator before you can log in', + 'authenticity_short' => 'Auth', + 'authenticity' => 'Authenticity', 'confidentiality' => 'Confidentiality', - 'confidentiality_short' => 'C', + 'confidentiality_short' => 'Conf', 'integrity' => 'Intégrity', - 'integrity_short' => 'I', + 'integrity_short' => 'Int', 'availability' => 'Availability', - 'availability_short' => 'A', + 'availability_short' => 'Av', 'tracability' => 'Traçability', - 'tracability_short' => 'T', + 'tracability_short' => 'Tra', 'old' => 'Old', 'active' => 'Active', ]; diff --git a/resources/lang/fr/cruds.php b/resources/lang/fr/cruds.php index 2b71f085..18c401df 100644 --- a/resources/lang/fr/cruds.php +++ b/resources/lang/fr/cruds.php @@ -340,6 +340,13 @@ 'size' => 'Taille', 'status' => 'Etat' ], + 'parameters' => [ + 'title' => 'Paramètres', + 'title_short' => 'Paramètres', + 'help' => 'Cet écran permet de configurer des paramètres optionnels de Mercator', + 'security_need_auth_helper' => 'Ajoute le critère de sécurité "Authenticité" aux critères Confidentialité, Intégrité, Disponibilité et Traçabilité déjà existants (exigence DORA).', + 'security_need_auth' => 'Authenticité', + ], ], 'database' => [ 'description' => 'Ensemble structuré et ordonné d’informations destinées à être exploitées informatiquement.', diff --git a/resources/lang/fr/global.php b/resources/lang/fr/global.php index 539de185..c5cd5e25 100644 --- a/resources/lang/fr/global.php +++ b/resources/lang/fr/global.php @@ -70,6 +70,8 @@ 'yes' => 'Oui', 'confidentiality' => 'Confidentialité', 'confidentiality_short' => 'C', + 'authenticity_short' => 'A', + 'authenticity' => 'Authenticité', 'integrity' => 'Intégrité', 'integrity_short' => 'I', 'availability' => 'Disponibilité', diff --git a/resources/views/admin/applications/create.blade.php b/resources/views/admin/applications/create.blade.php index ff027f74..52dd5477 100644 --- a/resources/views/admin/applications/create.blade.php +++ b/resources/views/admin/applications/create.blade.php @@ -424,6 +424,22 @@ class="recommended" + @if (config('mercator-config.parameters.security_need_auth')) + + + + + {{ trans("global.authenticity") }} + + + @endif @if($errors->has('security_need')) diff --git a/resources/views/admin/applications/edit.blade.php b/resources/views/admin/applications/edit.blade.php index 7bfa40d8..0ab1698e 100644 --- a/resources/views/admin/applications/edit.blade.php +++ b/resources/views/admin/applications/edit.blade.php @@ -386,7 +386,7 @@
-
+