Merge pull request #1550 from GSA/notify-api-1548

try to fix dynamic scan warnings
This commit is contained in:
ccostino
2025-02-07 14:32:55 -05:00
committed by GitHub
6 changed files with 25 additions and 3 deletions

View File

@@ -286,6 +286,13 @@ def init_app(app):
@app.after_request
def after_request(response):
response.headers.add("X-Content-Type-Options", "nosniff")
# Some dynamic scan findings
response.headers.add("Cross-Origin-Opener-Policy", "same-origin")
response.headers.add("Cross-Origin-Embedder-Policy", "require-corp")
response.headers.add("Cross-Origin-Resource-Policy", "same-origin")
response.headers.add("Cross-Origin-Opener-Policy", "same-origin")
return response
@app.errorhandler(Exception)

View File

@@ -52,7 +52,8 @@ def cleanup_unfinished_jobs():
# The query already checks that the processing_finished time is null, so here we are saying
# if it started more than 4 hours ago, that's too long
try:
acceptable_finish_time = job.processing_started + timedelta(minutes=5)
if job.processing_started is not None:
acceptable_finish_time = job.processing_started + timedelta(minutes=5)
except TypeError:
current_app.logger.exception(
f"Job ID {job.id} processing_started is {job.processing_started}.",

View File

@@ -694,7 +694,12 @@ def get_single_month_notification_stats_by_user(service_id, user_id):
service_id, start_date, end_date, user_id
)
stats = get_specific_days_stats(results, start_date, end_date=end_date, total_notifications=total_notifications,)
stats = get_specific_days_stats(
results,
start_date,
end_date=end_date,
total_notifications=total_notifications,
)
return jsonify(stats)