-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
2419 lines (2200 loc) · 154 KB
/
Makefile
File metadata and controls
2419 lines (2200 loc) · 154 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# ------------------------------------------------------------
# cawk is subjet to a MIT open-source licence
# please refer to the MIT licence file for further information
# ------------------------------------------------------------
# cawk is Copyright (C) 2024-2026 by Cedric Llorens
# ------------------------------------------------------------
# ---------------
include Makefile.support.mk
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# HELP and TARGETS
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
.PHONY: all version check_repo check_run check_run_audit tests tests_target view_repo view_run view_repo_error view_run_error clean_force clean_report clean_backup clean_tmp clean clean clean_report_repo clean_report_run clean_report_run_audit clean_archive_older clean_archive_repo clean_archive_run clean_archive_run_audit catalog_repo catalog_run git gitpush gitcheckdist supplier check_supplier system common create_audit delete_audit list_audit archive_run archive_repo check_parallel check_update check sync_run sync_run_audit backup_run backup_run_audit restore_run restore_run_audit database_view database_sync_add database_sync_update database_sync_del database_email_add database_email_update database_email_del email_send email_send_audit database_target_sh tests_check tests_run_copy tests_run_audit_copy database_postaudit_add database_postaudit_del migrate database_postaudit_update database_scripts_copy sync_run_audit_psirt sync_teststoconfs_run_audit sync_teststoconfs_run catalog_build_repo catalog_build_run catalog_build_run_audit
all:
$(ECHO) "# ---------------------------------------------------------------------------------------------------------------"
$(ECHO) "# -- CAWK INFO --------------------------------------------------------------------------------------------------"
$(ECHO) "# ---------------------------------------------------------------------------------------------------------------"
$(ECHO) "# note : %SED_GAWK_PATH% point out the gawk path, we set <!/usr/bin/env -S gawk -f> (ref support/tests.sed)"
$(ECHO) "# note : Makefile.support.mk contains variables that can change the cawk behavior"
$(ECHO) "# note : you can have several targets for a same gmake call like -> gmake clean check_repo view_repo"
$(ECHO) "# note : <repo> is the original cawk repository of coded tests, test's confs and exceptions"
$(ECHO) "# note : <run> is an empty repository used for your own tests/checks"
$(ECHO) "# note : <run_AUDIT_NAME> are repositories for all of your contexts or for your customers"
$(ECHO) "# note : please refer to the README file for further information"
$(ECHO) "# ---------------------------------------------------------------------------------------------------------------"
$(ECHO) "# -- CAWK VERSION------------------------------------------------------------------------------------------------"
$(ECHO) "# ---------------------------------------------------------------------------------------------------------------"
$(ECHO) "# gmake version : provide information on cawk release"
$(ECHO) "# ---------------------------------------------------------------------------------------------------------------"
$(ECHO) "# -- CAWK MAIN --------------------------------------------------------------------------------------------------"
$(ECHO) "# ---------------------------------------------------------------------------------------------------------------"
$(ECHO) "# gmake : provide information on cawk running"
$(ECHO) "# gmake check : allow to run a cawk compliance check (result must be OK only after the first installation)"
$(ECHO) "# gmake system : allow to know if the system can run cawk"
$(ECHO) "# gmake supplier : provide the suppliers supported by cawk"
$(ECHO) "# gmake common : provide the list of functions available in the common dir"
$(ECHO) "# gmake clean : clean tests && tmp repository"
$(ECHO) "# gmake clean_report_repo / clean_report_run / clean_report_run audit=AUDIT_NAME : clean reports"
$(ECHO) "# gmake clean_archive_repo / clean_archive_run / clean_archive_run audit=AUDIT_NAME : clean archives"
$(ECHO) "# gmake clean_archive_older : clean older archives (ref ARCHIVE_OLDER_DAYS variable in Makefile.support.mk)"
$(ECHO) "# gmake clean_backup : clean all backups"
$(ECHO) "# gmake clean_force : (USE WITH CAUTION) clean all including reports, backups, archives for all assessments"
$(ECHO) "# ---------------------------------------------------------------------------------------------------------------"
$(ECHO) "# -- CAWK TESTS -------------------------------------------------------------------------------------------------"
$(ECHO) "# ---------------------------------------------------------------------------------------------------------------"
$(ECHO) "# gmake tests_check : check if the tests are cawk compliant, all cawk pass and cawk error are displayed"
$(ECHO) "# gmake tests_check_nok : check if the tests are cawk compliant, only cawk error are displayed"
$(ECHO) "# gmake tests_common : build tests associated to common dir"
$(ECHO) "# gmake tests_repo : build tests associated to repo dir"
$(ECHO) "# gmake tests_run : build tests associated to run dir"
$(ECHO) "# gmake tests_run audit=AUDIT_NAME : build tests associated to run_audit dir"
$(ECHO) "# gmake tests_run_audit : build tests associated to all audit=AUDIT_NAME run_audit dirs"
$(ECHO) "# CAUTION : for update or migration purpose, it will replace all the same repo tests in the run_audit dir"
$(ECHO) "# CAUTION : user specific tests will remaint in the run_audit dir"
$(ECHO) "# NOTE : only available for audit=AUDIT_NAME assessments"
$(ECHO) "# gmake tests_run_copy audit=AUDIT_NAME : copy tests from repo to audit=AUDIT_NAME (ref run_audit)"
$(ECHO) "# gmake tests_run_audit_copy : copy tests from repo to all audit=AUDIT_NAMEs (ref all run_audit)"
$(ECHO) "# ---------------------------------------------------------------------------------------------------------------"
$(ECHO) "# -- CAWK ASSESSMENT --------------------------------------------------------------------------------------------"
$(ECHO) "# ---------------------------------------------------------------------------------------------------------------"
$(ECHO) "# gmake create_audit audit=AUDIT_NAME : create AUDIT_NAME tests, exceptions, confs directories (ref run_audit)"
$(ECHO) "# gmake delete_audit audit=AUDIT_NAME : delete AUDIT_NAME tests, exceptions, confs directories (ref run_audit)"
$(ECHO) "# gmake list_audit : list all the AUDIT_NAMEs (audit=AUDIT_NAME)"
$(ECHO) "# gmake run_audit : run assessments for all the AUDIT_NAMEs (audit=AUDIT_NAME)"
$(ECHO) "# ---------------------------------------------------------------------------------------------------------------"
$(ECHO) "# -- CAWK CHECK -------------------------------------------------------------------------------------------------"
$(ECHO) "# ---------------------------------------------------------------------------------------------------------------"
$(ECHO) "# NOTE : PSIRT=yes, DEADBEEF=yes, etc. can be added to the gmake call to enable/disable specific test groups"
$(ECHO) "# gmake check_repo : assess the confs with <repo> tests (build tests if not)"
$(ECHO) "# or gmake check_repo (run all suppliers)"
$(ECHO) "# or gmake check_repo supplier=cisco-ios (or view_juniper-junos, etc.)"
$(ECHO) "# gmake check_run : assess the confs with <run> tests (build tests if not)"
$(ECHO) "# or gmake check_run (run all suppliers)"
$(ECHO) "# or gmake check_run supplier=cisco-ios (or view_juniper-junos, etc.)"
$(ECHO) "# or gmake check_run audit=AUDIT_NAME (run all suppliers)"
$(ECHO) "# or gmake check_run supplier=cisco-ios audit=AUDIT_NAME (or view_juniper-junos, etc.)"
$(ECHO) "# gmake check_run_audit : run assessments for all the audit=AUDIT_NAMEs"
$(ECHO) "# ---------------------------------------------------------------------------------------------------------------"
$(ECHO) "# -- CAWK VIEW --------------------------------------------------------------------------------------------------"
$(ECHO) "# ---------------------------------------------------------------------------------------------------------------"
$(ECHO) "# gmake view_repo : view the repo reports (all in report/repo dir)"
$(ECHO) "# or gmake view_repo supplier=cisco-ios (or juniper-junos, etc.)"
$(ECHO) "# gmake view_repo_error : view the repo assessment reports errors (all in report/repo dir)"
$(ECHO) "# or gmake view_repo_error supplier=cisco-ios (or juniper-junos, etc.)"
$(ECHO) "# gmake view_run : view the run reports (all in report/run or run_audit dirs)"
$(ECHO) "# or gmake view_run supplier=cisco-ios (or juniper-junos, etc.)"
$(ECHO) "# or gmake view_run supplier=cisco-ios audit=AUDIT_NAME (or juniper-junos, etc.)"
$(ECHO) "# gmake view_run_error : view the run assessment reports errors (all in report/run or run_audit dirs)"
$(ECHO) "# or gmake view_run_error audit=AUDIT_NAME (all in report/repo dir)"
$(ECHO) "# or gmake view_run_error supplier=cisco-ios audit=AUDIT_NAME (or juniper-junos, etc.)"
$(ECHO) "# ---------------------------------------------------------------------------------------------------------------"
$(ECHO) "# -- CAWK DATABASE ----------------------------------------------------------------------------------------------"
$(ECHO) "# ---------------------------------------------------------------------------------------------------------------"
$(ECHO) "# NOTE : only available for audit=AUDIT_NAME assessments"
$(ECHO) "# gmake database_view : view all the databases linked to audit=AUDIT_NAME assessments"
$(ECHO) "# ---- sync ----"
$(ECHO) "# gmake database_sync_(add,update) audit=AUDIT_NAME dir=SYNC_PATH regex=REGEX_PATTERN/.* scope=SCOPE_FILE/none"
$(ECHO) "# add/update an entry in the cawk sync database, where fields are separated by spaces :"
$(ECHO) "# - 1 field is the audit name"
$(ECHO) "# - 2 field is the various sync paths separated by comma (no space) like /conf/ or /conf/cawk/,/conf/cawk_2/"
$(ECHO) "# - 3 field is an extended regex to select devices pattern matching like .* or .*switch.*"
$(ECHO) "# - 4 field is a file containing a list of devices matching a device scope based on internal inventory"
$(ECHO) "# - 5 field is an extended regex to select os pattern matching like (cisco-ios|cisco-xe) or .*"
$(ECHO) "# - 6 field is an extended regex to exclude device path pattern matching like (_home|_earth) or none"
$(ECHO) "# gmake database_sync_del audit=AUDIT_NAME : delete an entry in the cawk sync database"
$(ECHO) "# ---- email ----"
$(ECHO) "# gmake database_email_(add,update) audit=AUDIT_NAME dst=EMAIL_LIST cc=EMAIL_LIST/none"
$(ECHO) "# add/update an entry in the cawk email database, where fields are separated by spaces :"
$(ECHO) "# - 1 field is the audit name"
$(ECHO) "# - 2 field is the dst list of emails separated by comma (no space) like email1,email2,email3"
$(ECHO) "# - 3 field is the cc list of emails separated by comma (no space) like email1,email2,email3 or none"
$(ECHO) "# gmake database_email_del audit=AUDIT_NAME : delete an entry in the cawk email database"
$(ECHO) "# ---- post audit ----"
$(ECHO) "# gmake database_postaudit_(add/del/update) audit=AUDIT_NAME"
$(ECHO) "# add/delete an entry in the cawk post audit database, where fields are separated by spaces :"
$(ECHO) "# - 1 field is the audit name"
$(ECHO) "# ---------------------------------------------------------------------------------------------------------------"
$(ECHO) "# -- CAWK SYNC --------------------------------------------------------------------------------------------------"
$(ECHO) "# ---------------------------------------------------------------------------------------------------------------"
$(ECHO) "# NOTE : only available for audit=AUDIT_NAME assessment"
$(ECHO) "# NOTE : it relies on the cawk sync database (i.e.README)"
$(ECHO) "# CAUTION : local confs files are removed during sync (confs/run_audit dir) (i.e.README)"
$(ECHO) "# gmake sync_run audit=AUDIT_NAME : build inventory and sync confs from a central repository to confs/run_audit dir"
$(ECHO) "# gmake sync_run_audit : build inventory and sync confs from a central repository to all confs/run_audit dirs"
$(ECHO) "# gmake sync_psirt : build psirt inventory to be used by psirt tests"
$(ECHO) "# gmake sync_teststoconfs_run : sync tests to confs for audit=AUDIT_NAME assessment"
$(ECHO) "# gmake sync_teststoconfs_run_audit : sync tests to confs for only all audit=AUDIT_NAME assessments"
$(ECHO) "# ---------------------------------------------------------------------------------------------------------------"
$(ECHO) "# -- CAWK EMAIL -------------------------------------------------------------------------------------------------"
$(ECHO) "# ---------------------------------------------------------------------------------------------------------------"
$(ECHO) "# NOTE : only available for audit=AUDIT_NAME assessment"
$(ECHO) "# gmake email_send audit=AUDIT_NAME : send an email to the audit list of emails"
$(ECHO) "# gmake email_send_audit : send an email to all audits list of emails"
$(ECHO) "# ---------------------------------------------------------------------------------------------------------------"
$(ECHO) "# -- CAWK BACKUP AND RESTORE ------------------------------------------------------------------------------------"
$(ECHO) "# ---------------------------------------------------------------------------------------------------------------"
$(ECHO) "# NOTE : only available for audit=AUDIT_NAME assessment"
$(ECHO) "# gmake backup_run audit=AUDIT_NAME : backup all data linked to audit=AUDIT_NAME in backup dir"
$(ECHO) "# gmake restore_run audit=AUDIT_NAME file=BACKUP_PATH_FILE : restore all data from file_path"
$(ECHO) "# gmake backup_run_audit : backup cawk database and all data linked to all audit=AUDIT_NAMEs in backup dir"
$(ECHO) "# gmake restore_run_audit file=BACKUP_PATH_FILE : restore database and all data from file_path"
$(ECHO) "# gmake migrate file=BACKUP_PATH_FILE : run several targets to migrate to a new cakw version (i.e.README)"
$(ECHO) "# ---------------------------------------------------------------------------------------------------------------"
$(ECHO) "# -- CAWK CATALOG -----------------------------------------------------------------------------------------------"
$(ECHO) "# ---------------------------------------------------------------------------------------------------------------"
$(ECHO) "# gmake catalog_repo : build the tests description catalog for repo"
$(ECHO) "# gmake catalog_run : build the tests description catalog for run"
$(ECHO) "# gmake catalog_run audit=AUDIT_NAME: build the tests description catalog for audit=AUDIT_NAME"
$(ECHO) "# ---------------------------------------------------------------------------------------------------------------"
version:
@$(ECHO) "cawk version: " $(CAWK_RELEASE)
@$(ECHO) "cawk version done ----"
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# CREATE/DELETE AUDIT MANAGEMENT TARGETS
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
create_audit:
ifeq ($(strip $(audit)),)
$(ECHO) "cawk error audit=AUDIT_NAME must be set ----"
else
ifneq ($(wildcard $(REPORT_PATH)/run_${audit}/.),)
$(ECHO) "cawk error audit=${audit} already exist ----"
else
cp -r $(TESTS_PATH)/repo $(TESTS_PATH)/run_${audit}
cp -r $(EXCEPTION_PATH)/repo exceptions/run_${audit}
cp -r $(CONFS_PATH)/repo $(CONFS_PATH)/run_${audit}
mkdir $(REPORT_PATH)/run_${audit}
mkdir $(REPORT_PATH)/run_${audit}/archives
mkdir $(LOGS_PATH)/run_${audit}
gmake database_postaudit_add audit=${audit}
gmake database_email_add audit=${audit} dst=none cc=none
gmake database_sync_add audit=${audit} dir=none regex=.* scope=none regexos=.* regexpathexclude=none
endif
endif
$(ECHO) "cawk create_audit end ----"
delete_audit:
ifeq ($(strip $(audit)),)
$(ECHO) "cawk error audit=AUDIT_NAME must be set ----"
else
ifeq ($(wildcard $(REPORT_PATH)/run_${audit}/.),)
$(ECHO) "cawk error audit=${audit} do not exist ----"
else
rm -f -r $(TESTS_PATH)/run_${audit}
rm -f -r $(CONFS_PATH)/run_${audit}
rm -f -r $(EXCEPTION_PATH)/run_${audit}
rm -f -r $(REPORT_PATH)/run_${audit}
rm -f -r $(LOGS_PATH)/run_${audit}
$(EGREP) "^${audit}" $(DATABASE_PATH)/db_sync.txt > /dev/null && sed -i "/^${audit}/d" $(DATABASE_PATH)/db_sync.txt || true
$(EGREP) "^${audit}" $(DATABASE_PATH)/db_postaudit.txt > /dev/null && sed -i "/^${audit}/d" $(DATABASE_PATH)/db_postaudit.txt || true
$(EGREP) "^${audit}" $(DATABASE_PATH)/db_email.txt > /dev/null && sed -i "/^${audit}/d" $(DATABASE_PATH)/db_email.txt || true
endif
endif
$(ECHO) "cawk delete_audit end ----"
list_audit:
find tests -name '*run_*' -type d | awk -F'run_' '{print $$NF}' | sort -u
$(ECHO) "cawk list_audit end ----"
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# DATABASE MANAGEMENT TARGETS
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
database_view:
touch $(DATABASE_PATH)/db_sync.txt
touch $(DATABASE_PATH)/db_email.txt
touch $(DATABASE_PATH)/db_postaudit.txt
$(ECHO) "\n-------------------------------------------"
$(ECHO) "cawk view $(DATABASE_PATH)/db_sync.txt"
$(ECHO) "-------------------------------------------"
cat $(DATABASE_PATH)/db_sync.txt | sort || true
$(ECHO) "\n-------------------------------------------"
$(ECHO) "cawk view $(DATABASE_PATH)/db_email.txt"
$(ECHO) "-------------------------------------------"
cat $(DATABASE_PATH)/db_email.txt | sort || true
$(ECHO) "\n-------------------------------------------"
$(ECHO) "cawk view $(DATABASE_PATH)/db_postaudit.txt"
$(ECHO) "-------------------------------------------"
cat $(DATABASE_PATH)/db_postaudit.txt | sort || true
$(ECHO) "\n-------------------------------------------"
$(ECHO) "cawk database_view done ----"
database_sync_add:
touch $(DATABASE_PATH)/db_sync.txt
ifeq ($(strip $(audit)),)
$(ECHO) "cawk error audit=AUDIT_NAME must be set ----"
else
ifeq ($(wildcard $(REPORT_PATH)/run_${audit}/.),)
$(ECHO) "cawk error audit=${audit} do not exist ----"
else
ifeq ($(strip $(dir)),)
$(ECHO) "cawk error dir=SYNC_PATH must be set ----"
else
ifeq ($(strip $(regex)),)
$(ECHO) "cawk error regex=REGEX_PATTERN/.* must be set ----"
else
ifeq ($(strip $(scope)),)
$(ECHO) "cawk error scope=SCOPE_FILE/none must be set ----"
else
ifeq ($(strip $(regexos)),)
$(ECHO) "cawk error regexos=REGEX_PATTERN_OS/.* must be set ----"
else
ifeq ($(strip $(regexpathexclude)),)
$(ECHO) "cawk error regexpathexclude=REGEX_PATTERN_PATH_EXCLUDE/none must be set ----"
else
$(ECHO) "${audit} ${dir} ${regex} ${scope} ${regexos} $(regexpathexclude)" >> $(DATABASE_PATH)/db_sync.txt
endif
endif
endif
endif
endif
endif
endif
$(ECHO) "cawk database_sync_add end ----"
database_sync_update:
touch $(DATABASE_PATH)/db_sync.txt
ifeq ($(strip $(audit)),)
$(ECHO) "cawk error audit=AUDIT_NAME must be set ----"
else
ifeq ($(wildcard $(REPORT_PATH)/run_${audit}/.),)
$(ECHO) "cawk error audit=${audit} do not exist ----"
else
ifeq ($(strip $(dir)),)
$(ECHO) "cawk error dir=SYNC_PATH_DIR must be set ----"
else
ifeq ($(strip $(regex)),)
$(ECHO) "cawk error regex=REGEX_PATTERN/.* must be set ----"
else
ifeq ($(strip $(scope)),)
$(ECHO) "cawk error scope=SCOPE_FILE/none must be set ----"
else
ifeq ($(strip $(regexos)),)
$(ECHO) "cawk error regexos=REGEX_PATTERN_OS/.* must be set ----"
else
ifeq ($(strip $(regexpathexclude)),)
$(ECHO) "cawk error regexpathexclude=REGEX_PATTERN_PATH_EXCLUDE/none must be set ----"
else
$(ECHO) "cawk update $(DATABASE_PATH)/db_sync.txt"
@sed -i "/^$(audit)/d" $(DATABASE_PATH)/db_sync.txt
$(ECHO) "${audit} ${dir} ${regex} ${scope} ${regexos} $(regexpathexclude)" >> $(DATABASE_PATH)/db_sync.txt
endif
endif
endif
endif
endif
endif
endif
$(ECHO) "cawk database_sync_add end ----"
database_sync_del:
touch $(DATABASE_PATH)/db_sync.txt
ifeq ($(strip $(audit)),)
$(ECHO) "cawk error audit=AUDIT_NAME must be set ----"
else
ifeq ($(wildcard $(REPORT_PATH)/run_${audit}/.),)
$(ECHO) "cawk error audit=${audit} do not exist ----"
else
$(ECHO) "cawk update $(DATABASE_PATH)/db_sync.txt"
sed -i "/^$(audit)/d" $(DATABASE_PATH)/db_sync.txt
endif
endif
$(ECHO) "cawk database_sync_add end ----"
database_postaudit_add:
touch $(DATABASE_PATH)/db_postaudit.txt
ifeq ($(strip $(audit)),)
$(ECHO) "cawk error audit=AUDIT_NAME must be set ----"
else
ifeq ($(wildcard $(REPORT_PATH)/run_${audit}/.),)
$(ECHO) "cawk error audit=${audit} do not exist ----"
else
$(ECHO) "cawk update $(DATABASE_PATH)/db_postaudit.txt"
$(ECHO) "${audit}" >> $(DATABASE_PATH)/db_postaudit.txt
endif
endif
$(ECHO) "cawk database_postaudit_add end ----"
database_postaudit_update:
touch $(DATABASE_PATH)/db_postaudit.txt
ifeq ($(strip $(audit)),)
$(ECHO) "cawk error audit=AUDIT_NAME must be set ----"
else
ifeq ($(wildcard $(REPORT_PATH)/run_${audit}/.),)
$(ECHO) "cawk error audit=${audit} do not exist ----"
else
$(ECHO) "cawk update $(DATABASE_PATH)/db_postaudit.txt"
sed -i "/^$(audit)/d" $(DATABASE_PATH)/db_postaudit.txt
$(ECHO) "${audit}" >> $(DATABASE_PATH)/db_postaudit.txt
endif
endif
$(ECHO) "cawk database_postaudit_add end ----"
database_postaudit_del:
touch $(DATABASE_PATH)/db_postaudit.txt
ifeq ($(strip $(audit)),)
$(ECHO) "cawk error audit=AUDIT_NAME must be set ----"
else
ifeq ($(wildcard $(REPORT_PATH)/run_${audit}/.),)
$(ECHO) "cawk error audit=${audit} do not exist ----"
else
$(ECHO) "cawk update $(DATABASE_PATH)/db_postaudit.txt"
sed -i "/^$(audit)/d" $(DATABASE_PATH)/db_postaudit.txt
endif
endif
$(ECHO) "cawk database_postaudit_add end ----"
database_email_add:
touch $(DATABASE_PATH)/db_email.txt
ifeq ($(strip $(audit)),)
$(ECHO) "cawk error audit=AUDIT_NAME must be set ----"
else
ifeq ($(strip $(dst)),)
$(ECHO) "cawk error dst=RECIPIENT_EMAIL must be set ----"
else
cc=$(strip $(cc))
if [ -z "$$cc" ]; then cc=none; fi; \
$(ECHO) "cawk update $(DATABASE_PATH)/db_email.txt"; \
$(ECHO) "$(audit) $(dst) $$cc" >> $(DATABASE_PATH)/db_email.txt
endif
endif
$(ECHO) "cawk email_database_add end ----"
database_email_update:
touch $(DATABASE_PATH)/db_email.txt
ifeq ($(strip $(audit)),)
$(ECHO) "cawk error audit=AUDIT_NAME must be set ----"
else
ifeq ($(strip $(dst)),)
$(ECHO) "cawk error dst=RECIPIENT_EMAIL must be set ----"
else
cc=$(strip $(cc))
if [ -z "$$cc" ]; then cc=none; fi; \
$(ECHO) "cawk update $(DATABASE_PATH)/db_email.txt"; \
sed -i "/^$(audit)/d" $(DATABASE_PATH)/db_email.txt
$(ECHO) "${audit} ${dst} ${cc}" >> $(DATABASE_PATH)/db_email.txt
endif
endif
$(ECHO) "cawk email_database_update end ----"
database_email_del:
touch $(DATABASE_PATH)/db_email.txt
ifeq ($(strip $(audit)),)
$(ECHO) "cawk error audit=AUDIT_NAME must be set ----"
else
$(ECHO) "cawk update $(DATABASE_PATH)/db_email.txt"
sed -i "/^$(audit)/d" $(DATABASE_PATH)/db_email.txt
endif
$(ECHO) "cawk email_database_del end ----"
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# SYNC MANAGEMENT TARGETS
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
sync_run: clean_tmp tests_target_common database_target_sh
if [ ! -f $(DATABASE_PATH_SH)/database_sync.script ]; then \
$(ECHO) "cawk error: $(DATABASE_PATH_SH)/database_sync.script does not exist, execution skipped ----"; \
else \
$(ECHO) "cawk $(DATABASE_PATH_SH)/database_sync.script execution ----"; \
$(DATABASE_PATH_SH)/database_sync.script ${audit}; \
fi
ifeq ($(strip $(audit)),)
$(ECHO) "cawk error audit=AUDIT_NAME must be set ----"
$(ECHO) "cawk sync_run done ----"
else
$(ECHO) "cawk cleaning local configurations before sync : $(CONFS_PATH)/run_${audit} "
rm -f -r $(CONFS_PATH)/run_${audit} || true
mkdir -p $(CONFS_PATH)/run_${audit} || true
$(ECHO) "cawk sync files from $(DATABASE_PATH)/db_sync.txt"
$(EGREP) "^$(audit)" $(DATABASE_PATH)/db_sync.txt | while read line; do \
paths=$$($(ECHO) "$$line" | gawk '{print $$2}'); \
if [ "$$paths" != "none" ]; then \
regex=$$($(ECHO) "$$line" | gawk '{print $$3}'); \
scope=$$($(ECHO) "$$line" | gawk '{if ( $$4 == "") { print "none"; } else { print $$4; }}'); \
regexos=$$($(ECHO) "$$line" | gawk '{if ( $$5 == "") { print "none"; } else { print $$5; }}'); \
regexpathexclude=$$($(ECHO) "$$line" | gawk '{if ( $$6 == "") { print "none"; } else { print $$6; }}'); \
cd $(CONFS_PATH)/run_$(audit) && ../../$(COMMON_PATH)/sync_cawk_conf.gawk "$$paths" "$$regex" "../../$$scope" "$$regexos" "$$regexpathexclude" && cd ../.. ; \
else \
$(ECHO) "cawk error: $(DATABASE_PATH)/db_sync.txt audit $$($(ECHO) "$$line" | gawk '{print $$1}') path does not exist, execution skipped ----"; \
fi \
done
$(ECHO) "cawk sync_run_audit ${audit} done ----"
endif
sync_run_audit:
cat $(DATABASE_PATH)/db_sync.txt | while read line; do \
audit=$$($(ECHO) "$$line" | gawk '{print $$1}'); \
gmake sync_run audit=$$audit; \
done
gmake list_audit
$(ECHO) "cawk you may launch <gmake sync_teststoconfs_run_audit> to sync tests supplier scope to tests supplier scope ----"
$(ECHO) "cawk sync_run_audit all audit done ----"
sync_psirt:
if [ ! -f $(DATABASE_PATH_SH)/database_sync_psirt.script ]; then \
$(ECHO) "cawk error: $(DATABASE_PATH_SH)/database_sync_psirt.script does not exist, execution skipped ----"; \
else \
$(ECHO) "cawk $(DATABASE_PATH_SH)/database_sync_psirt.script execution ----"; \
$(DATABASE_PATH_SH)/database_sync_psirt.script ${audit}; \
fi
$(ECHO) "cawk sync_run_audit_psirt done ----"
sync_teststoconfs_run:
ifeq ($(strip $(audit)),)
$(ECHO) "cawk error audit=AUDIT_NAME must be set ----"
$(ECHO) "cawk sync_teststoconfs_run done ----"
else
$(ECHO) "\ncawk sync_teststoconfs_run: processing audit $(audit) ----"
if [ ! -d "$(CONFS_PATH)/run_$(audit)" ]; then \
$(ECHO) "cawk sync_teststoconfs_run: confs/run_$(audit) not found, skip ----"; \
exit 0; \
fi; \
keep=""; \
for s in $(SUPPLIER_SCOPE); do \
if [ -d "$(CONFS_PATH)/run_$(audit)/confs.$$s" ]; then \
keep="$$keep $$s"; \
fi; \
done; \
if [ -z "$$keep" ]; then \
$(ECHO) "cawk sync_teststoconfs_run: no suppliers found in confs/run_$(audit), skip ----"; \
exit 0; \
fi; \
for t in $(TESTS_PATH)/run_$(audit)/*; do \
if [ ! -e "$$t" ]; then continue; fi; \
name=$$(basename $$t); \
sup=$$(echo $$name | sed -e 's/^tests\.//' -e 's/\.psirt$$//' ); \
found=no; \
for ks in $$keep; do \
if [ "$$ks" = "$$sup" ]; then found=yes; break; fi; \
done; \
if [ "$$found" = "no" ]; then \
$(ECHO) "cawk sync_teststoconfs_run: removing $$t (supplier=$$sup not present in confs/run_$(audit)) ----"; \
rm -rf "$$t" || true; \
else \
$(ECHO) "cawk sync_teststoconfs_run: keep $$t (supplier=$$sup)"; \
fi; \
done; \
$(ECHO) "cawk sync_teststoconfs_run $(audit) done ----"
endif
$(ECHO) "cawk sync_teststoconfs_run done ----"
sync_teststoconfs_run_audit:
@for audit in $(RUN_DIRS); do \
$(ECHO) "\ncawk sync_teststoconfs_run_audit: processing audit $$audit ----"; \
if [ ! -d "$(CONFS_PATH)/run_$$audit" ]; then \
$(ECHO) "cawk sync_teststoconfs_run_audit: confs/run_$$audit not found, skip ----"; \
continue; \
fi; \
keep=""; \
for s in $(SUPPLIER_SCOPE); do \
if [ -d "$(CONFS_PATH)/run_$$audit/confs.$$s" ]; then \
keep="$$keep $$s"; \
fi; \
done; \
if [ -z "$$keep" ]; then \
continue; \
fi; \
for t in $(TESTS_PATH)/run_$$audit/*; do \
if [ ! -e "$$t" ]; then continue; fi; \
name=$$(basename $$t); \
# normalize tests directory name to supplier (tests.<supplier> or tests.<supplier>.psirt) \
sup=$$(echo $$name | sed -e 's/^tests\.//' -e 's/\.psirt$$//' ); \
found=no; \
for ks in $$keep; do \
if [ "$$ks" = "$$sup" ]; then found=yes; break; fi; \
done; \
if [ "$$found" = "no" ]; then \
$(ECHO) "cawk sync_teststoconfs_run_audit: removing $$t (supplier=$$sup not present in confs/run_$$audit) ----"; \
rm -rf "$$t" || true; \
else \
$(ECHO) "cawk sync_teststoconfs_run_audit: keep $$t (supplier=$$sup)"; \
fi; \
done; \
done; \
$(ECHO) "cawk sync_teststoconfs_run_audit done ----"
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# POSTAUDIT MANAGEMENT TARGETS
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
postaudit_run: clean tests_target_common database_target_sh
ifeq ($(strip $(audit)),)
$(ECHO) "cawk error audit=AUDIT_NAME must be set ----"
$(ECHO) "cawk postaudit_run done ----"
else
if [ ! -f $(DATABASE_PATH_SH)/database_postaudit.script ]; then \
$(ECHO) "cawk error: $(DATABASE_PATH_SH)/database_postaudit.script does not exist, execution skipped ----"; \
else \
$(ECHO) "cawk $(DATABASE_PATH_SH)/database_postaudit.script execution ----"; \
$(DATABASE_PATH_SH)/database_postaudit.script ${audit}; \
fi
$(ECHO) "cawk postaudit_run ${audit} done ----"
endif
postaudit_run_audit:
cat $(DATABASE_PATH)/db_postaudit.txt | while read line; do \
$(ECHO) $$line ; \
audit=$$line; \
gmake postaudit_run audit=$$audit; \
done
gmake list_audit
$(ECHO) "cawk postaudit_run_audit all audit done ----"
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# EMAIL MANAGEMENT TARGETS
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
email_send:
ifeq ($(strip $(audit)),)
$(ECHO) "cawk error audit=AUDIT_NAME must be set ----"
else
ifeq ($(wildcard $(REPORT_PATH)/run_${audit}/.),)
$(ECHO) "cawk error audit=${audit} do not exist ----"
else
if $(EGREP) -q "^${audit} " $(DATABASE_PATH)/db_email.txt; then \
email_info=$$($(EGREP) "^${audit} " $(DATABASE_PATH)/db_email.txt); \
dst=$$($(ECHO) $$email_info | awk '{print $$2}'); \
cc=$$($(ECHO) $$email_info | awk '{print $$3}'); \
if [ -z "$$dst" ]; then \
$(ECHO) "cawk error dst not found for audit ${audit} ----"; \
exit 0; \
fi; \
if [ -z "$$(find $(REPORT_PATH)/run_${audit} -name '*.csv' -type f)" ]; then \
$(ECHO) "cawk error no csv files found in $(REPORT_PATH)/run_${audit} ----"; \
exit 0; \
fi; \
zip -j -9 -q $(REPORT_PATH)/run_${audit}/assessment.run_${audit}.export.zip $$(find $(REPORT_PATH)/run_${audit} -type f \( -name '*all.summary.txt' -o -name '*all.idx' -o -name '*all.security.timeline.csv' -o -name '*all.audit.timeline.csv' -o -name '*all.psirt.timeline.csv' -o -name '*all.exception.timeline.csv' -o -name '*all.deadbeef.timeline.csv' \)) || true; \
$(ECHO) "cawk sending audit ${audit} to $$dst ----"; \
if [ "$$cc" != "none" ]; then \
if [ -n "$$(find $(REPORT_PATH)/run_${audit} -name '*all.summary.txt' -type f)" ]; then \
cat $(COMMON_PATH)/common_message.txt | mutt -s "cawk ${audit} assessment" -a $(REPORT_PATH)/run_${audit}/*all.summary.txt -a $(REPORT_PATH)/run_${audit}/assessment.run_${audit}.export.zip -c $$cc -- $$dst; \
else \
cat $(COMMON_PATH)/common_message.txt | mutt -s "cawk ${audit} assessment" -a $(REPORT_PATH)/run_${audit}/*all.summary.txt -a $(REPORT_PATH)/run_${audit}/assessment.run_${audit}.export.zip -c $$cc -- $$dst; \
fi; \
else \
if [ -n "$$(find $(REPORT_PATH)/run_${audit} -name '*all.summary.txt' -type f)" ]; then \
cat $(COMMON_PATH)/common_message.txt | mutt -s "cawk ${audit} assessment" -a $(REPORT_PATH)/run_${audit}/*all.summary.txt -a $(REPORT_PATH)/run_${audit}/assessment.run_${audit}.export.zip -- $$dst; \
else \
cat $(COMMON_PATH)/common_message.txt | mutt -s "cawk ${audit} assessment" -a $(REPORT_PATH)/run_${audit}/*all.summary.txt -a $(REPORT_PATH)/run_${audit}/assessment.run_${audit}.export.zip -- $$dst; \
fi; \
fi; \
$(ECHO) "cawk email sent successfully ----"; \
else \
$(ECHO) "cawk error no email info found for audit ${audit} ----"; \
fi
endif
endif
$(ECHO) "cawk send_audit_email end ----"
email_send_audit:
for audit in $(RUN_DIRS); do \
gmake email_send audit=$$audit; \
done
$(ECHO) "cawk email_send_audit done ----"
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# BACKUP/RESTORE MANAGEMENT TARGETS
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
backup_run: clean
ifeq ($(strip $(audit)),)
$(ECHO) "cawk error audit=AUDIT_NAME must be set ----"
$(ECHO) "cawk backup_run done ----"
else
rm -f backup/run_audit_${audit}_$(shell date +%Y-%m-%d).tar.gz backup/run_audit_${audit}_$(shell date +%Y-%m-%d).tar
find confs/run_${audit}* -type l -exec rm {} \; 2>/dev/null || true
find confs/run_${audit}* logs/run_${audit}* tests/run_${audit}* exceptions/run_${audit}* reports/run_${audit}* -type f -print0 | tar cvf backup/run_audit_${audit}_$(shell date +%Y-%m-%d).tar --null -T - >/dev/null 2>&1
gzip backup/run_audit_${audit}_$(shell date +%Y-%m-%d).tar
$(ECHO) "cawk backup_run_audit ${audit} done in backup/run_audit_${audit}_$(shell date +%Y-%m-%d).tar.gz ----"
endif
backup_run_audit: clean
rm -f backup/run_audit_$(shell date +%Y-%m-%d).tar backup/run_audit_$(shell date +%Y-%m-%d).tar.gz
find confs/run_* -type l -exec rm {} \; 2>/dev/null || true
find $(DATABASE_PATH)/* logs/run_* confs/run_* tests/run_* exceptions/run_* reports/run_* -type f -print0 | tar cvf backup/run_audit_$(shell date +%Y-%m-%d).tar --null -T - >/dev/null 2>&1
gzip backup/run_audit_$(shell date +%Y-%m-%d).tar
gmake list_audit
$(ECHO) "cawk backup_run_audit all audits done in backup/run_audit_$(shell date +%Y-%m-%d).tar.gz ----"
restore_run: clean
ifeq ($(strip $(audit)),)
$(ECHO) "cawk error audit=AUDIT_NAME and file=BACKUP_PATH_FILE must be set ----"
$(ECHO) "cawk restore_run done ----"
else
ifeq ($(strip $(file)),)
$(ECHO) "cawk error audit=AUDIT_NAME and file=BACKUP_PATH_FILE must be set ----"
$(ECHO) "cawk restore_run done ----"
else
if [ -f ${file} ]; then \
tar -xzvf ${file} >/dev/null 2>&1; \
$(ECHO) "cawk restore_run ${audit} done ----"; \
else \
$(ECHO) "cawk error: file ${file} does not exist ----"; \
fi
endif
endif
mkdir -p confs/run_${audit} 2>/dev/null || true
$(ECHO) "cawk creates audit confs directory (empty case): confs/run_${audit}"
restore_run_audit: clean
ifeq ($(strip $(file)),)
$(ECHO) "cawk error file=BACKUP_PATH_FILE must be set ----"
$(ECHO) "cawk restore_run_audit done ----"
else
if [ -f ${file} ]; then \
tar -xzvf ${file} >/dev/null 2>&1; \
$(ECHO) "cawk restore_run_audit done ----"; \
else \
$(ECHO) "cawk error: file ${file} does not exist ----"; \
fi
endif
@for dir in $$(find tests -name '*run_*' -type d | grep -o 'run_[^/]*'); do \
mkdir -p confs/$$dir 2>/dev/null || true; \
$(ECHO) "cawk creates audit directory (empty case): confs/$$dir"; \
done
migrate:
ifeq ($(strip $(file)),)
$(ECHO) "cawk error file=BACKUP_PATH_FILE must be set ----"
exit 0
endif
cp ${file} backup/
gmake restore_run_audit file=backup/$(notdir ${file})
gmake tests_run_audit_copy
gmake tests_common tests_run_audit
# --------------------------------
check_supplier:
ifneq ($(strip $(supplier)),)
ifneq ($(findstring $(supplier),$(SUPPLIER_SCOPE)),$(supplier))
$(ECHO) "cawk error ($(supplier)) is not the list of suppliers covered by cawk ($(SUPPLIER_SCOPE)) ----"
exit 0
endif
endif
supplier:
$(ECHO) $(SUPPLIER_SCOPE)
$(ECHO) "cawk supplier done ----"
# --------------------------------
system:
$(TESTS_SYSTEM)/cawk_check_system
# --------------------------------
common:
$(EGREP) purpose common/*.template
# --------------------------------
# Mark temporary files for automatic cleanup
.INTERMEDIATE: $(REPORT_PATH)/repo/*.swap $(REPORT_PATH)/run/*.swap $(REPORT_PATH)/run_*/*.swap
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# TESTS MANAGEMENT TARGETS
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
tests_target_common: $(TESTS_COMMON_TEMPLATE:.gawk.template=.gawk) $(TESTS_COMMON_SH:.script.sh=.script)
database_target_sh: $(DATABASE_SH:.script.sh=.script)
tests_check: tests_target_common tests_target_repo tests_target_run
find tests -name '*.gawk' -type f -exec common/check_test.gawk {} \; | awk '/cawk test pass/ {print "\033[32m" $$0 "\033[0m"} !/cawk test pass/ {print "\033[31m" $$0 "\033[0m"}'
$(ECHO) "cawk tests_check done ----"
tests_check_nok: tests_target_common tests_target_repo tests_target_run
find tests -name '*.gawk' -type f -exec common/check_test.gawk {} \; | awk '/cawk test pass/ {print "\033[32m" $$0 "\033[0m"} !/cawk test pass/ {print "\033[31m" $$0 "\033[0m"}' | $(EGREP) "cawk test error" || true
$(ECHO) "cawk tests_check done ----"
tests_target_repo: tests_target_common\
$(SUPPLIER_M4_REPO_FILES) \
$(SUPPLIER_M4_REPO_PSIRT_FILES) \
$(SUPPLIER_TEMPLATE_REPO_FILES) \
$(SUPPLIER_TEMPLATE_REPO_PSIRT_FILES) \
$(SUPPLIER_INCLUDE_REPO_PSIRT_FILES) \
$(EXCEPTION_M4:.m4=)
tests_target_run: tests_target_common \
$(SUPPLIER_M4_RUN_FILES) \
$(SUPPLIER_M4_RUN_PSIRT_FILES) \
$(SUPPLIER_TEMPLATE_RUN_FILES) \
$(SUPPLIER_TEMPLATE_RUN_PSIRT_FILES) \
$(SUPPLIER_INCLUDE_RUN_PSIRT_FILES) \
$(EXCEPTION_M4:.m4=)
tests_common: tests_target_common
$(ECHO) "cawk tests_common done ----"
tests_repo: tests_target_repo
$(ECHO) "cawk tests_repo done ----"
tests_run_copy:
ifeq ($(strip $(audit)),)
$(ECHO) "cawk error audit=AUDIT_NAME must be set ----"
else
for supplier in $(SUPPLIER_SCOPE); do \
if [ ! -d "$(TESTS_PATH)/repo/tests.$$supplier" ]; then \
$(ECHO) "cawk error: $(TESTS_PATH)/repo/tests.$$supplier does not exist ----"; \
elif [ -d "$(TESTS_PATH)/repo/tests.$$supplier" ]; then \
$(ECHO) "cawk tests_repo_copy $$supplier to run_$$audit start ----"; \
mkdir -p $(TESTS_PATH)/run_$$audit/tests.$$supplier || true; \
find $(TESTS_PATH)/repo/tests.$$supplier -name "*.template" -exec cp -v {} $(TESTS_PATH)/run_$$audit/tests.$$supplier/ \; || true; \
find $(TESTS_PATH)/repo/tests.$$supplier -name "*.m4" -exec cp -v {} $(TESTS_PATH)/run_$$audit/tests.$$supplier/ \; || true; \
$(ECHO) "cawk tests_repo_copy $$supplier to run_$$audit done ----"; \
fi; \
if [ ! -d "$(TESTS_PATH)/repo/tests.$$supplier.psirt" ]; then \
$(ECHO) "cawk error: $(TESTS_PATH)/repo/tests.$$supplier.psirt does not exist ----"; \
elif [ -d "$(TESTS_PATH)/repo/tests.$$supplier.psirt" ]; then \
$(ECHO) "cawk tests_repo_copy $$supplier.psirt to run_$$audit start ----"; \
mkdir -p $(TESTS_PATH)/run_$$audit/tests.$$supplier.psirt || true; \
find $(TESTS_PATH)/repo/tests.$$supplier.psirt -name "*.template" -exec cp -v {} $(TESTS_PATH)/run_$$audit/tests.$$supplier.psirt/ \; || true; \
find $(TESTS_PATH)/repo/tests.$$supplier.psirt -name "*.m4" -exec cp -v {} $(TESTS_PATH)/run_$$audit/tests.$$supplier.psirt/ \; || true; \
find $(TESTS_PATH)/repo/tests.$$supplier.psirt -name "*.include" -exec cp -v {} $(TESTS_PATH)/run_$$audit/tests.$$supplier.psirt/ \; || true; \
$(ECHO) "cawk tests_repo_copy $$supplier.psirt to run_$$audit done ----"; \
fi; \
done
endif
tests_run_audit_copy:
for dir in $(RUN_DIRS); do \
audit=$$dir; \
for supplier in $(SUPPLIER_SCOPE); do \
if [ ! -d "$(TESTS_PATH)/repo/tests.$$supplier" ]; then \
$(ECHO) "cawk error: $(TESTS_PATH)/repo/tests.$$supplier does not exist ----"; \
elif [ -d "$(TESTS_PATH)/repo/tests.$$supplier" ]; then \
$(ECHO) "cawk tests_repo_copy $$supplier to run_$$audit start ----"; \
mkdir -p $(TESTS_PATH)/run_$$audit/tests.$$supplier || true; \
find $(TESTS_PATH)/repo/tests.$$supplier -name "*.template" -exec cp -v {} $(TESTS_PATH)/run_$$audit/tests.$$supplier/ \; || true; \
find $(TESTS_PATH)/repo/tests.$$supplier -name "*.m4" -exec cp -v {} $(TESTS_PATH)/run_$$audit/tests.$$supplier/ \; || true; \
$(ECHO) "cawk tests_repo_copy $$supplier to run_$$audit done ----"; \
fi; \
if [ ! -d "$(TESTS_PATH)/repo/tests.$$supplier.psirt" ]; then \
$(ECHO) "cawk error: $(TESTS_PATH)/repo/tests.$$supplier.psirt does not exist ----"; \
elif [ -d "$(TESTS_PATH)/repo/tests.$$supplier.psirt" ]; then \
$(ECHO) "cawk tests_repo_copy $$supplier.psirt to run_$$audit tart ----"; \
mkdir -p $(TESTS_PATH)/run_$$audit/tests.$$supplier.psirt || true; \
find $(TESTS_PATH)/repo/tests.$$supplier.psirt -name "*.template" -exec cp -v {} $(TESTS_PATH)/run_$$audit/tests.$$supplier.psirt/ \; || true; \
find $(TESTS_PATH)/repo/tests.$$supplier.psirt -name "*.m4" -exec cp -v {} $(TESTS_PATH)/run_$$audit/tests.$$supplier.psirt/ \; || true; \
find $(TESTS_PATH)/repo/tests.$$supplier.psirt -name "*.include" -exec cp -v {} $(TESTS_PATH)/run_$$audit/tests.$$supplier.psirt/ \; || true; \
$(ECHO) "cawk tests_repo_copy $$supplier.psirt to run_$$audit done ----"; \
fi \
done; \
done
tests_run: tests_target_run
$(ECHO) "cawk tests_run $$audit done ----"
tests_run_audit:
@for dir in $(RUN_DIRS); do \
gmake tests_run audit=$$dir; \
done
$(ECHO) "cawk tests_run_audit end ----"
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# CHECK_REPO MANAGEMENT TARGETS
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
check_repo: clean_report_repo clean_tmp tests_repo check_supplier
ifneq ($(strip $(audit)),)
$(ECHO) "cawk error the use of <audit=AUDIT_NAME> can only be used with check_run target ----"
exit 0
else
ifeq ($(strip $(supplier)),)
ifeq ($(strip $(MAKE_PARALLEL)),no)
$(foreach scope,$(SUPPLIER_SCOPE),\
find $(CONFIGURATION_$(scope)_REPO_PATH) $(FIND_CONF_SELECT) -exec ./$(TESTS_COMMON_PATH)/deadbeef_cawk_conf.script $(DEADBEEF_THRESHOLD_DAYS) {} \; > $(REPORT_PATH)/repo/assessment.$(scope).deadbeef.csv 2>/dev/null || true ;\
cat $(REPORT_PATH)/repo/assessment.$(scope).deadbeef.csv >> $(REPORT_PATH)/repo/assessment.all.deadbeef.csv ;\
find $(CONFIGURATION_$(scope)_REPO_PATH) $(FIND_CONF_SELECT) > $(REPORT_PATH)/repo/assessment.$(scope).idx 2>/dev/null || true ;\
awk -v scope=$(scope) '{print $$0,scope}' $(REPORT_PATH)/repo/assessment.$(scope).idx >> $(REPORT_PATH)/repo/assessment.all.idx.swap ;\
)
awk 'BEGIN { FS = ";" } { print $$1; }' $(REPORT_PATH)/repo/assessment.all.deadbeef.csv > $(REPORT_PATH)/repo/assessment.all.deadbeef.idx
$(foreach scope,$(SUPPLIER_SCOPE),\
$(ECHO) "cawk compute repo $(scope) devices ----" ;\
\
$(if $(filter no,$(PSIRT)),\
$(foreach test,$(shell find $(TESTS_$(scope)_REPO_PATH) -name '*.gawk' -type f 2>/dev/null || true),\
find $(CONFIGURATION_$(scope)_REPO_PATH) $(FIND_CONF_SELECT) $(TEST_EXE) >> $(REPORT_PATH)/repo/assessment.$(scope).csv.swap 2>/dev/null || true ;\
),\
touch $(REPORT_PATH)/repo/assessment.$(scope).csv.swap ;\
) \
$(foreach test,$(shell find $(TESTS_$(scope)_REPO_PSIRT_PATH) -name '*.gawk' -type f 2>/dev/null || true),\
find $(CONFIGURATION_$(scope)_REPO_PATH) $(FIND_CONF_SELECT) $(TEST_EXE) >> $(REPORT_PATH)/repo/assessment.$(scope).csv.swap 2>/dev/null || true ;\
) \
)
$(foreach scope,$(SUPPLIER_SCOPE),\
$(EGREP) -v -f $(EXCEPTION_PATH)/repo/exceptions.$(scope) $(REPORT_PATH)/repo/assessment.$(scope).csv.swap | sort -u > $(REPORT_PATH)/repo/assessment.$(scope).csv || true ;\
cat $(REPORT_PATH)/repo/assessment.$(scope).csv | sort -u >> $(REPORT_PATH)/repo/assessment.all.csv.swap ;\
$(EGREP) -f $(EXCEPTION_PATH)/repo/exceptions.$(scope) $(REPORT_PATH)/repo/assessment.$(scope).csv.swap | sort -u > $(REPORT_PATH)/repo/assessment.$(scope).exceptions.csv || true ;\
cat $(REPORT_PATH)/repo/assessment.$(scope).exceptions.csv | sort -u >> $(REPORT_PATH)/repo/assessment.all.exception.csv ;\
$(TESTS_COMMON_PATH)/report.gawk $(REPORT_PATH)/repo/assessment.all.deadbeef.csv $(REPORT_PATH)/repo/assessment.$(scope).exceptions.csv $(REPORT_PATH)/repo/assessment.$(scope).csv > $(REPORT_PATH)/repo/assessment.$(scope).summary.txt ;\
)
$(foreach scope,$(SUPPLIER_SCOPE),\
$(ECHO) "------------------------" >> $(REPORT_PATH)/repo/assessment.$(scope).summary.txt;\
$(ECHO) "---- tests purposes ----" >> $(REPORT_PATH)/repo/assessment.$(scope).summary.txt;\
$(ECHO) "------------------------" >> $(REPORT_PATH)/repo/assessment.$(scope).summary.txt;\
gmake catalog_repo | $(EGREP) "tests/" | $(EGREP) $(scope) | sort >> $(REPORT_PATH)/repo/assessment.$(scope).summary.txt ;\
)
ifeq ($(strip $(DEADBEEF)),yes)
$(ECHO) "cawk deadbeef filter performed ----"
$(EGREP) -v -f $(REPORT_PATH)/repo/assessment.all.deadbeef.idx $(REPORT_PATH)/repo/assessment.all.csv.swap > $(REPORT_PATH)/repo/assessment.all.csv
else
$(ECHO) "cawk deadbeef filter skipped ----"
mv $(REPORT_PATH)/repo/assessment.all.csv.swap $(REPORT_PATH)/repo/assessment.all.csv || true
endif
$(TESTS_COMMON_PATH)/report.gawk $(REPORT_PATH)/repo/assessment.all.deadbeef.csv $(REPORT_PATH)/repo/assessment.all.exception.csv $(REPORT_PATH)/repo/assessment.all.csv > $(REPORT_PATH)/repo/assessment.all.summary.txt
$(ECHO) "------------------------" >> $(REPORT_PATH)/repo/assessment.all.summary.txt
$(ECHO) "---- tests purposes ----" >> $(REPORT_PATH)/repo/assessment.all.summary.txt
$(ECHO) "------------------------" >> $(REPORT_PATH)/repo/assessment.all.summary.txt
gmake catalog_repo | $(EGREP) "tests/" | sort >> $(REPORT_PATH)/repo/assessment.all.summary.txt
$(EGREP) '(high|medium|low);error' $(REPORT_PATH)/repo/assessment.all.csv > $(REPORT_PATH)/repo/assessment.all.security.csv || true
$(TESTS_COMMON_PATH)/report_timeline.gawk $(REPORT_PATH)/repo/assessment.all.idx.swap $(REPORT_PATH)/repo/assessment.all.security.csv > $(REPORT_PATH)/repo/assessment.all.security.timeline.csv || true
$(EGREP) ';psirt' $(REPORT_PATH)/repo/assessment.all.csv > $(REPORT_PATH)/repo/assessment.all.psirt.csv || true
$(TESTS_COMMON_PATH)/report_timeline.gawk $(REPORT_PATH)/repo/assessment.all.idx.swap $(REPORT_PATH)/repo/assessment.all.psirt.csv > $(REPORT_PATH)/repo/assessment.all.psirt.timeline.csv || true
$(EGREP) '(info;error|;warning)' $(REPORT_PATH)/repo/assessment.all.csv > $(REPORT_PATH)/repo/assessment.all.audit.csv || true
$(TESTS_COMMON_PATH)/report_timeline.gawk $(REPORT_PATH)/repo/assessment.all.idx.swap $(REPORT_PATH)/repo/assessment.all.audit.csv > $(REPORT_PATH)/repo/assessment.all.audit.timeline.csv || true
$(TESTS_COMMON_PATH)/report_timeline.gawk $(REPORT_PATH)/repo/assessment.all.idx.swap $(REPORT_PATH)/repo/assessment.all.csv > $(REPORT_PATH)/repo/assessment.all.timeline.csv
$(TESTS_COMMON_PATH)/report_timeline.gawk $(REPORT_PATH)/repo/assessment.all.idx.swap $(REPORT_PATH)/repo/assessment.all.exception.csv > $(REPORT_PATH)/repo/assessment.all.exception.timeline.csv
$(TESTS_COMMON_PATH)/report_timeline.gawk $(REPORT_PATH)/repo/assessment.all.idx.swap $(REPORT_PATH)/repo/assessment.all.deadbeef.csv > $(REPORT_PATH)/repo/assessment.all.deadbeef.timeline.csv
sort -u $(REPORT_PATH)/repo/assessment.all.idx.swap > $(REPORT_PATH)/repo/assessment.all.idx
ifeq ($(strip $(TMP_ASSESSMENT_FILES)),yes)
$(ECHO) "cawk removing temporary assessment files ----"
$(foreach scope,$(SUPPLIER_SCOPE),\
rm -f $(REPORT_PATH)/repo/assessment.$(scope).* || true ;\
)
rm -f $(REPORT_PATH)/repo/assessment.all.*.swap || true
else
$(ECHO) "cawk keeping assessment files ----"
endif
ifeq ($(strip $(JSON)),yes)
$(ECHO) "cawk json reporting performed ----"
$(TESTS_COMMON_PATH)/report_json.gawk $(REPORT_PATH)/repo/assessment.all.csv > $(REPORT_PATH)/repo/assessment.all.json
$(TESTS_COMMON_PATH)/report_json.gawk $(REPORT_PATH)/repo/assessment.all.security.csv > $(REPORT_PATH)/repo/assessment.all.security.json
$(TESTS_COMMON_PATH)/report_json.gawk $(REPORT_PATH)/repo/assessment.all.audit.csv > $(REPORT_PATH)/repo/assessment.all.audit.json
$(TESTS_COMMON_PATH)/report_json.gawk $(REPORT_PATH)/repo/assessment.all.psirt.csv > $(REPORT_PATH)/repo/assessment.all.psirt.json
$(TESTS_COMMON_PATH)/report_json.gawk $(REPORT_PATH)/repo/assessment.all.exception.csv > $(REPORT_PATH)/repo/assessment.all.exception.json
$(TESTS_COMMON_PATH)/report_sumjson.gawk $(REPORT_PATH)/repo/assessment.all.summary.txt > $(REPORT_PATH)/repo/assessment.all.summary.json
else
$(ECHO) "cawk json reporting skipped ----"
endif
else
$(foreach scope,$(SUPPLIER_SCOPE),\
find $(CONFIGURATION_$(scope)_REPO_PATH) $(FIND_CONF_SELECT) -exec ./$(TESTS_COMMON_PATH)/deadbeef_cawk_conf.script $(DEADBEEF_THRESHOLD_DAYS) {} \; > $(REPORT_PATH)/repo/assessment.$(scope).deadbeef.csv 2>/dev/null || true ;\
cat $(REPORT_PATH)/repo/assessment.$(scope).deadbeef.csv >> $(REPORT_PATH)/repo/assessment.all.deadbeef.csv ;\
find $(CONFIGURATION_$(scope)_REPO_PATH) $(FIND_CONF_SELECT) > $(REPORT_PATH)/repo/assessment.$(scope).idx 2>/dev/null || true ;\
awk -v scope=$(scope) '{print $$0,scope}' $(REPORT_PATH)/repo/assessment.$(scope).idx >> $(REPORT_PATH)/repo/assessment.all.idx.swap ;\
)
awk 'BEGIN { FS = ";" } { print $$1; }' $(REPORT_PATH)/repo/assessment.all.deadbeef.csv > $(REPORT_PATH)/repo/assessment.all.deadbeef.idx
$(foreach scope,$(SUPPLIER_SCOPE),\
$(ECHO) "cawk compute repo $(scope) devices (parallel mode) ----" ;\
find $(CONFIGURATION_$(scope)_REPO_PATH) $(FIND_CONF_SELECT) > $(TESTS_TMP)/conf_list_files.repo.$(scope) 2>/dev/null || true ;\
\
$(if $(filter no,$(PSIRT)),\
find $(TESTS_$(scope)_REPO_PATH) -type f -name '*.gawk' > $(TESTS_TMP)/conf_list_tests.repo.$(scope) 2>/dev/null || true ;\
$(TESTS_COMMON_PATH)/gen_cawk_makefile.gawk $(TESTS_TMP)/conf_list_files.repo.$(scope) $(MAKE_FILES_PER_TARGET) $(TESTS_TMP)/conf_list_tests.repo.$(scope) > $(TESTS_TMP)/Makefile.repo.$(scope) 2>/dev/null || true ;\
gmake -f $(TESTS_TMP)/Makefile.repo.$(scope) -j $(MAKE_J) --load-average=$(MAKE_LOAD_AVG) all >> $(REPORT_PATH)/repo/assessment.$(scope).csv.swap 2>/dev/null || true ;\
, \
touch $(REPORT_PATH)/repo/assessment.$(scope).csv.swap ;\
) \
)
$(foreach scope,$(SUPPLIER_SCOPE),\
find $(TESTS_$(scope)_REPO_PSIRT_PATH) -type f -name '*.gawk' > $(TESTS_TMP)/conf_list_tests.repo.psirt.$(scope) 2>/dev/null || true ;\
$(TESTS_COMMON_PATH)/gen_cawk_makefile.psirt.gawk $(TESTS_TMP)/conf_list_files.repo.$(scope) $(MAKE_FILES_PER_TARGET_PSIRT) $(TESTS_TMP)/conf_list_tests.repo.psirt.$(scope) > $(TESTS_TMP)/Makefile.repo.psirt.$(scope) 2>/dev/null || true ;\
gmake -f $(TESTS_TMP)/Makefile.repo.psirt.$(scope) -j $(MAKE_J) --load-average=$(MAKE_LOAD_AVG) all >> $(REPORT_PATH)/repo/assessment.$(scope).csv.swap 2>/dev/null || true ;\
)
$(foreach scope,$(SUPPLIER_SCOPE),\
$(EGREP) -v -f $(EXCEPTION_PATH)/repo/exceptions.$(scope) $(REPORT_PATH)/repo/assessment.$(scope).csv.swap | sort -u > $(REPORT_PATH)/repo/assessment.$(scope).csv || true ;\
cat $(REPORT_PATH)/repo/assessment.$(scope).csv | sort -u >> $(REPORT_PATH)/repo/assessment.all.csv.swap ;\
$(EGREP) -f $(EXCEPTION_PATH)/repo/exceptions.$(scope) $(REPORT_PATH)/repo/assessment.$(scope).csv.swap | sort -u > $(REPORT_PATH)/repo/assessment.$(scope).exceptions.csv || true ;\
cat $(REPORT_PATH)/repo/assessment.$(scope).exceptions.csv | sort -u >> $(REPORT_PATH)/repo/assessment.all.exception.csv ;\
$(TESTS_COMMON_PATH)/report.gawk $(REPORT_PATH)/repo/assessment.all.deadbeef.csv $(REPORT_PATH)/repo/assessment.$(scope).exceptions.csv $(REPORT_PATH)/repo/assessment.$(scope).csv > $(REPORT_PATH)/repo/assessment.$(scope).summary.txt ;\
$(ECHO) "------------------------\n---- tests purposes ----\n------------------------" >> $(REPORT_PATH)/repo/assessment.$(scope).summary.txt;\
gmake catalog_repo | $(EGREP) "tests/" | $(EGREP) $(scope) | sort >> $(REPORT_PATH)/repo/assessment.$(scope).summary.txt ;\
)
ifeq ($(strip $(DEADBEEF)),yes)
$(ECHO) "cawk deadbeef filter performed ----"
$(EGREP) -v -f $(REPORT_PATH)/repo/assessment.all.deadbeef.idx $(REPORT_PATH)/repo/assessment.all.csv.swap > $(REPORT_PATH)/repo/assessment.all.csv || true
else
$(ECHO) "cawk deadbeef filter skipped ----"
mv $(REPORT_PATH)/repo/assessment.all.csv.swap $(REPORT_PATH)/repo/assessment.all.csv || true
endif
$(TESTS_COMMON_PATH)/report.gawk $(REPORT_PATH)/repo/assessment.all.deadbeef.csv $(REPORT_PATH)/repo/assessment.all.exception.csv $(REPORT_PATH)/repo/assessment.all.csv > $(REPORT_PATH)/repo/assessment.all.summary.txt
$(ECHO) "------------------------" >> $(REPORT_PATH)/repo/assessment.all.summary.txt
$(ECHO) "---- tests purposes ----" >> $(REPORT_PATH)/repo/assessment.all.summary.txt
$(ECHO) "------------------------" >> $(REPORT_PATH)/repo/assessment.all.summary.txt
gmake catalog_repo | $(EGREP) "tests/" | sort >> $(REPORT_PATH)/repo/assessment.all.summary.txt
$(EGREP) '(high|medium|low);error' $(REPORT_PATH)/repo/assessment.all.csv > $(REPORT_PATH)/repo/assessment.all.security.csv || true
$(TESTS_COMMON_PATH)/report_timeline.gawk $(REPORT_PATH)/repo/assessment.all.idx.swap $(REPORT_PATH)/repo/assessment.all.security.csv > $(REPORT_PATH)/repo/assessment.all.security.timeline.csv || true
$(EGREP) ';psirt' $(REPORT_PATH)/repo/assessment.all.csv > $(REPORT_PATH)/repo/assessment.all.psirt.csv || true
$(TESTS_COMMON_PATH)/report_timeline.gawk $(REPORT_PATH)/repo/assessment.all.idx.swap $(REPORT_PATH)/repo/assessment.all.psirt.csv > $(REPORT_PATH)/repo/assessment.all.psirt.timeline.csv || true