Skip to content

Commit

Permalink
chore: Log md5 hash of body content for CA POST call (#763)
Browse files Browse the repository at this point in the history
* chore: Log md5 hash of body content for CA POST call

* Made linter happy
  • Loading branch information
dgpatelgit authored Jun 1, 2021
1 parent 1735ddc commit 73409be
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bayesian/api/api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import logging
from typing import Dict
import json
import hashlib
from pydantic.error_wrappers import ValidationError

from flask import Blueprint, request, redirect
Expand Down Expand Up @@ -115,6 +116,12 @@ def component_analyses_post():
input_json: Dict = request.get_json()
ecosystem: str = input_json.get('ecosystem')
if request.user_agent.string == "claircore/crda/RemoteMatcher":
try:
md5_hash = hashlib.md5(json.dumps(input_json, sort_keys=True).
encode('utf-8')).hexdigest()
logger.info("Ecosystem: %s => body md5 hash: %s", ecosystem, md5_hash)
except Exception as e:
logger.error("Exception %s", e)
return jsonify({"message": "disabled"}), 404
try:
# Step1: Gather and clean Request
Expand Down

0 comments on commit 73409be

Please sign in to comment.