88FIPS_PROTECTED_DIRECTORIES = [b'arch/x86/crypto/' , b'cypto/asymmetric_keys/' , b'crypto/' , b'drivers/crypto/' ,
99 b'drivers/char/random.c' , b'include/crypto' ]
1010
11+ DEBUG = False
12+
1113def find_common_tag (old_tags , new_tags ):
1214 for tag in old_tags :
1315 if tag in new_tags :
@@ -43,10 +45,11 @@ def check_for_fips_protected_changes(repo, branch, common_tag):
4345
4446 num_commits = len (results .stdout .split (b'\n ' ))
4547 print ('[rolling release update] Number of commits to check: ' , num_commits )
46- shas_to_check = []
48+ shas_to_check = {}
4749 commits_checked = 0
4850
4951 print ('[rolling release update] Checking modifications of shas' )
52+ print (results .stdout .split (b'\n ' ))
5053 for sha in results .stdout .split (b'\n ' ):
5154 commits_checked += 1
5255 if commits_checked % (num_commits // 10 ) == 0 :
@@ -61,19 +64,38 @@ def check_for_fips_protected_changes(repo, branch, common_tag):
6164 exit (1 )
6265
6366 sha_hash_and_subject = b''
67+ touched_fips_files = set ()
68+ is_rebuild = False
69+
6470 for line in res .stdout .split (b'\n ' ):
6571 if sha_hash_and_subject == b'' :
6672 sha_hash_and_subject = line
73+ if b'Rebuild rocky' in line :
74+ is_rebuild = True
6775 continue
6876 if line == b'' :
6977 continue
7078
79+ add_to_check = False
80+
7181 for dir in FIPS_PROTECTED_DIRECTORIES :
7282 if line .startswith (dir ):
73- print (f'FIPS protected directory change found in commit { sha } ' )
74- print (sha_hash_and_subject )
75- shas_to_check .append (sha_hash_and_subject .split (b' ' )[0 ])
76- sha_hash_and_subject = b''
83+ if DEBUG :
84+ print (f'FIPS protected directory { dir } change found in commit { sha } ' )
85+ print (sha_hash_and_subject )
86+ add_to_check = True
87+ if dir not in touched_fips_files :
88+ touched_fips_files .add (dir )
89+
90+ if add_to_check :
91+ shas_to_check [sha_hash_and_subject .split (b' ' )[0 ]] = touched_fips_files
92+
93+ if touched_fips_files :
94+ print (f'[rolling release update] Checked commit { sha } touched { len (touched_fips_files )} FIPS protected files' )
95+ for f in touched_fips_files :
96+ print (f' - { f } ' )
97+ sha_hash_and_subject = b''
98+
7799 print (f'[rolling release update] { len (shas_to_check )} of { num_commits } commits have FIPS protected changes' )
78100
79101 return shas_to_check
@@ -91,13 +113,20 @@ def check_for_fips_protected_changes(repo, branch, common_tag):
91113 action = 'store_true' )
92114 parser .add_argument ('--demo' , help = 'DEMO mode, will make a new set of branches with demo_ prepended' ,
93115 action = 'store_true' )
116+ parser .add_argument ('--debug' , help = 'Enable debug output' , action = 'store_true' )
94117 args = parser .parse_args ()
95118
96119 if args .demo :
97120 print ('======================== DEMO MODE ENABLED ==========================' )
98121 print ('[rolling release update] DEMO mode enabled YOU SHOULD NOT COMMIT THIS' )
99122 print ('======================== DEMO MODE ENABLED ==========================' )
100123
124+ if args .debug :
125+ DEBUG = True
126+ print ('======================== DEBUG MODE ENABLED ==========================' )
127+ print ('[rolling release update] Debug mode enabled' )
128+ print ('======================== DEBUG MODE ENABLED ==========================' )
129+
101130 repo = git .Repo (args .repo )
102131
103132 rolling_product = args .old_rolling_branch .split ('/' )[0 ]
@@ -117,8 +146,14 @@ def check_for_fips_protected_changes(repo, branch, common_tag):
117146 print ('[rolling release update] Checking for FIPS protected changes between the common tag and HEAD' )
118147 shas_to_check = check_for_fips_protected_changes (repo , args .new_base_branch , latest_resf_sha )
119148 if shas_to_check and args .fips_override is False :
120- for sha in shas_to_check :
121- print (repo .git .show (sha .decode ()))
149+ for sha ,dir in shas_to_check .items ():
150+ print (f"## Commit { sha .decode ()} " )
151+ print ('\' \' \' ' )
152+ dir_list = []
153+ for d in dir :
154+ dir_list .append (d .decode ())
155+ print (repo .git .show (sha .decode (), dir_list ))
156+ print ('\' \' \' ' )
122157 print ('[rolling release update] FIPS protected changes found between the common tag and HEAD' )
123158 print ('[rolling release update] Please Contact the CIQ FIPS / Security team for further instructions' )
124159 print ('[rolling release update] Exiting' )
0 commit comments