MCPcopy Create free account
hub / github.com/adobe/Marinus / fetch_certificate_batch

Function fetch_certificate_batch

python3_cron_scripts/get_original_ct_logs.py:157–210  ·  view source on GitHub ↗

Fetch a range of records from the CT Log. Each log has its own limits on the number of records returned which means that the ending_index may be ignored.

(
    logger,
    url,
    starting_index,
    ending_index,
    jobs_manager,
    last_index_collection,
    source,
    job_number,
)

Source from the content-addressed store, hash-verified

155
156
157def fetch_certificate_batch(
158 logger,
159 url,
160 starting_index,
161 ending_index,
162 jobs_manager,
163 last_index_collection,
164 source,
165 job_number,
166):
167 """
168 Fetch a range of records from the CT Log.
169 Each log has its own limits on the number of records returned which means
170 that the ending_index may be ignored.
171 """
172 result = make_https_request(
173 logger,
174 url
175 + "/ct/v1/get-entries?start="
176 + str(starting_index)
177 + "&end="
178 + str(ending_index),
179 jobs_manager,
180 )
181
182 if result is None:
183 logger.error(
184 "ERROR on request with starting index "
185 + str(starting_index)
186 + " and ending index "
187 + str(ending_index)
188 )
189
190 # Some logs rate limit. Therefore, pause before giving it one more shot.
191 time.sleep(3610)
192
193 result = make_https_request(
194 logger,
195 url
196 + "/ct/v1/get-entries?start="
197 + str(starting_index)
198 + "&end="
199 + str(ending_index),
200 jobs_manager,
201 )
202
203 if result is None:
204 jobs_manager.record_job_error()
205 logger.error("FATAL: No result from get-entries", exc_info=True)
206 # Start one search back on the next round just to be sure
207 set_last_index(last_index_collection, source, starting_index - 256, job_number)
208 exit(1)
209
210 return json.loads(result)
211
212
213def fetch_starting_index(

Callers 1

mainFunction · 0.85

Calls 3

set_last_indexFunction · 0.85
record_job_errorMethod · 0.80
make_https_requestFunction · 0.70

Tested by

no test coverage detected