/ database / seeders / NormSeeder.php
NormSeeder.php
  1  <?php
  2  
  3  namespace Database\Seeders;
  4  
  5  use App\Models\Norm;
  6  use App\Models\NormGroup;
  7  use App\Models\NormScope;
  8  use Illuminate\Database\Seeder;
  9  use Illuminate\Support\Facades\DB;
 10  
 11  class NormSeeder extends Seeder
 12  {
 13      /**
 14       * Run the database seeds.
 15       *
 16       * @return void
 17       */
 18      public function run()
 19      {
 20  
 21          $normNames = [
 22              'Common Criteria',
 23              'LINCE',
 24              'ITSEC',
 25              'STIC',
 26              'ISO',
 27              'ITSEM',
 28              'IT009',
 29          ];
 30  
 31          $normAlias = [
 32              'CC',
 33              'LINCE',
 34              'ITSEC',
 35              'STIC',
 36              'ISO',
 37              'ITSEM',
 38              'IT009',
 39          ];
 40  
 41          foreach ($normNames as $key => $normName) {
 42              NormGroup::create([
 43                  'name' => $normName,
 44                  'description' => fake()->sentence(),
 45                  'url' => fake()->url(),
 46                  'alias' => $normAlias[$key]
 47              ]);
 48          }
 49  
 50          $normGroup = NormGroup::where('name', 'Common Criteria')->first();
 51          DB::table('norms')->insert($this->getNormsCC($normGroup->id));
 52          $normGroup->update([
 53              'mandatory_etrp' => 'ASE,AGD,ALC,ADV,ATE,AVA',
 54          ]);
 55  
 56          $normGroup = NormGroup::where('name', 'LINCE')->first();
 57          DB::table('norms')->insert($this->getNormsLINCE($normGroup->id));
 58  
 59          $normGroup = NormGroup::where('name', 'ITSEC')->first();
 60          DB::table('norms')->insert($this->getNormsITSEC($normGroup->id));
 61  
 62          $normGroup = NormGroup::where('name', 'ISO')->first();
 63          DB::table('norms')->insert($this->getNormsISO($normGroup->id));
 64  
 65          $normGroup = NormGroup::where('name', 'ITSEM')->first();
 66          DB::table('norms')->insert($this->getNormsITSEM($normGroup->id));
 67  
 68          $normGroup = NormGroup::where('name', 'IT009')->first();
 69          DB::table('norms')->insert($this->getNormsIT009($normGroup->id));
 70      }
 71  
 72      private function getNormsCC(int $normGroupId): array
 73      {
 74          /**Tiene que ser el mismo nombre que viene en el fichero */
 75  
 76          return [
 77              [
 78                  //"NOR",1,1,"Common Methodology for Information Technology Security Evaluation/Common Criteria for Information Technology Security Evaluation version 2","I","1","N","CC.ZIP"
 79                  'version' => 'v2',
 80                  'description' => 'CC v2',
 81                  'norm_group_id' => $normGroupId,
 82                  'oracle_code' => 1,
 83              ],
 84              [
 85                  //"NOR",2,1,"CC PARTE 2","I","0","N","CC.ZIP"
 86                  'version' => 'PARTE 2',
 87                  'description' => 'CC PARTE 2',
 88                  'norm_group_id' => $normGroupId,
 89                  'oracle_code' => 2,
 90              ],
 91              [
 92                  //"NOR",3,1,"CC PARTE 3","I","0","N","CC.ZIP"
 93                  'version' => 'PARTE 3',
 94                  'description' => 'CC PARTE 3',
 95                  'norm_group_id' => $normGroupId,
 96                  'oracle_code' => 3,
 97              ],
 98              [
 99                  //"NOR",8,1,"Common Methodology for Information Technology Security Evaluation/Common Criteria for Information Technology Security Evaluation version 3.1 release 1","I","1","N","CC31.ZIP"
100                  'version' => 'v3.1R1',
101                  'description' => 'CC v3.1R1',
102                  'norm_group_id' => $normGroupId,
103                  'oracle_code' => 8,
104              ],
105              [
106                  //"NOR",9,1,"Common Methodology for Information Technology Security Evaluation/Common Criteria for Information Technology Security Evaluation version 3.1 release 2","I","1","N","cc31_r2.zip"
107                  'version' => 'v3.1R2',
108                  'description' => 'CC v3.1R2',
109                  'norm_group_id' => $normGroupId,
110                  'oracle_code' => 9,
111              ],
112              [
113                  //"NOR",14,1,"Common Methodology for Information Technology Security Evaluation/Common Criteria for Information Technology Security Evaluation version 3.1 release 3","I","1","N","CC3.1R3-Final.zip"
114                  'version' => 'v3.1R3',
115                  'description' => 'CC v3.1R3',
116                  'norm_group_id' => $normGroupId,
117                  'oracle_code' => 14,
118              ],
119              [
120                  //"NOR",15,1,"Common Methodology for Information Technology Security Evaluation/Common Criteria for Information Technology Security Evaluation version 3.1 release 4","I","1","N","NOR-15.ZIP"
121                  'version' => 'v3.1R4',
122                  'description' => 'CC v3.1R4',
123                  'norm_group_id' => $normGroupId,
124                  'oracle_code' => 15,
125              ],
126              [
127                  //"NOR",17,1,"Common Methodology for Information Technology Security Evaluation/Common Criteria for Information Technology Security Evaluation version 3.1 release 5","I","1","N","NOR-17.zip"
128                  'version' => 'v3.1R5',
129                  'description' => 'CC v3.1R5',
130                  'norm_group_id' => $normGroupId,
131                  'oracle_code' => 17,
132              ],
133              [
134                  //"NOR",22,,"CC:2022 Release 1","D","1","N","NOR-22.zip"
135                  'version' => '2022 R1',
136                  'description' => 'CC:2022 R1',
137                  'norm_group_id' => $normGroupId,
138                  'oracle_code' => 22,
139              ]
140          ];
141      }
142  
143      private function getNormsLINCE(int $normGroupId): array
144      {
145          /**Tiene que ser el mismo nombre que viene en el fichero */
146  
147          return [
148              [
149                  //"NOR",20,1,"Certificación Nacional Esencial de Seguridad, versión 0.1","I","1","N","NOR-20.ZIP"
150                  'version' => '0.1',
151                  'description' => 'Certificación Nacional Esencial de Seguridad 0.1',
152                  'oracle_code' => 20,
153                  'norm_group_id' => $normGroupId,
154                  'data' => json_encode([
155                      'certification_table' => [
156                          [
157                              "name" => "CCN-STIC-2001",
158                              "description" => "Definición de la Certificación Nacional Esencial de Seguridad (LINCE), versión 0.1.<br>Enero 2020. Centro Criptológico Nacional."
159                          ],
160                          [
161                              "name" => "CCN-STIC-2002",
162                              "description" => "Metodología de Evaluación para la Certificación Nacional Esencial de Seguridad (LINCE), versión 0.1.<br> Enero 2020. Centro Criptológico Nacional."
163                          ],
164                          [
165                              "name" => "CCN-STIC-2003",
166                              "description" => "Plantilla para la Declaración de Seguridad de la Certificación Nacional Esencial de Seguridad (LINCE), versión 0.1.<br> Enero 2020. Centro Criptológico Nacional."
167                          ],
168                          [
169                              "name" => "CCN-STIC-2004",
170                              "description" => "Plantilla del Informe Técnico de Evaluación de la Certificación Nacional Esencial de Seguridad (LINCE), versión 0.1.<br> Enero 2020. Centro Criptológico Nacional."
171                          ]
172                      ]
173                  ]),
174              ],
175              [
176                  //"NOR",21,1,"Certificación Nacional Esencial de Seguridad, versión 2.0","I","1","N","NOR-21.zip"
177                  'version' => '2.0.0',
178                  'description' => 'Certificación Nacional Esencial de Seguridad 2.0.0',
179                  'oracle_code' => 21,
180                  'norm_group_id' => $normGroupId,
181                  'data' => json_encode([
182                      'certification_table' => [
183                          [
184                              "name" => "CCN-STIC-2001",
185                              "description" => "Definición de la Certificación Nacional Esencial de Seguridad (LINCE), versión 2.0.<br> Marzo 2022. Centro Criptológico Nacional."
186                          ],
187                          [
188                              "name" => "CCN-STIC-2002",
189                              "description" => "Metodología de Evaluación para la Certificación Nacional Esencial de Seguridad (LINCE), versión 2.0.<br> Marzo 2022. Centro Criptológico Nacional."
190                          ],
191                          [
192                              "name" => "CCN-STIC-2003",
193                              "description" => "Plantilla para la Declaración de Seguridad de la Certificación Nacional Esencial de Seguridad (LINCE), versión 2.0.<br> Marzo 2022. Centro Criptológico Nacional."
194                          ],
195                          [
196                              "name" => "CCN-STIC-2004",
197                              "description" => "Plantilla del Informe Técnico de Evaluación de la Certificación Nacional Esencial de Seguridad (LINCE), versión 2.0.<br> Marzo 2022. Centro Criptológico Nacional."
198                          ]
199                      ]
200                  ]),
201              ]
202          ];
203      }
204  
205      private function getNormsITSEC(int $normGroupId): array
206      {
207          return [
208              [
209                  //"NOR",5,1,"ITSEC","I","1","N","NOR-5.pdf"
210                  'version' => 'v1.2',
211                  'description' => 'ITSEC v1.2',
212                  'norm_group_id' => $normGroupId,
213                  'oracle_code' => 5,
214              ],
215          ];
216      }
217  
218      private function getNormsISO(int $normGroupId): array
219      {
220          return [
221              [
222                  //"NOR",19,1,"ISO/IEC 19790:2012 Information Technology - Security techniques - Security requirements for cryptographic modules","I","1","N","NOR-19.TXT"
223                  'version' => '19790:2012',
224                  'description' => 'ISO/IEC 19790:2012',
225                  'norm_group_id' => $normGroupId,
226                  'oracle_code' => 19,
227              ],
228              [
229                  //"NOR",4,1,"CEM","I","0","N","CC.ZIP"
230                  'version' => '15408',
231                  'description' => ' ISO/IEC 15408',
232                  'norm_group_id' => $normGroupId,
233                  'oracle_code' => 4,
234              ]
235          ];
236      }
237  
238      private function getNormsITSEM(int $normGroupId): array
239      {
240          return [
241              [
242                  //"NOR",6,1,"ITSEM","I","0","N","NOR-6.pdf"
243                  'version' => '',
244                  'description' => 'ITSEM',
245                  'norm_group_id' => $normGroupId,
246                  'oracle_code' => 6,
247              ],
248          ];
249      }
250  
251      private function getNormsIT009(int $normGroupId): array
252      {
253          return [
254              [
255                  //"NOR",7,1,"IT-009 - Remote Qualified Electronic Signature Creation Device Evaluation Methodology v1.0","I","0","N","docs_esquema.zip"
256                  'version' => 'v1.0',
257                  'description' => 'IT-009 v1.0',
258                  'norm_group_id' => $normGroupId,
259                  'oracle_code' => 7,
260              ],
261          ];
262      }
263  }