Skip to content

Commit

Permalink
do not require redis for read operations
Browse files Browse the repository at this point in the history
  • Loading branch information
northdpole committed Jul 29, 2024
1 parent 6a2b2c4 commit d879ac9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
20 changes: 18 additions & 2 deletions application/cmd/cre_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,57 +543,73 @@ def run(args: argparse.Namespace) -> None: # pragma: no cover
# individual resource importing
if args.zap_in:
from application.utils.external_project_parsers.parsers import zap_alerts_parser

BaseParser().register_resource(
zap_alerts_parser.ZAP, db_connection_str=args.cache_file
)
if args.cheatsheets_in:
from application.utils.external_project_parsers.parsers import cheatsheets_parser
from application.utils.external_project_parsers.parsers import (
cheatsheets_parser,
)

BaseParser().register_resource(
cheatsheets_parser.Cheatsheets, db_connection_str=args.cache_file
)
if args.github_tools_in:
from application.utils.external_project_parsers.parsers import misc_tools_parser

BaseParser().register_resource(
misc_tools_parser.MiscTools, db_connection_str=args.cache_file
)
if args.capec_in:
from application.utils.external_project_parsers.parsers import capec_parser

BaseParser().register_resource(
capec_parser.Capec, db_connection_str=args.cache_file
)
if args.cwe_in:
from application.utils.external_project_parsers.parsers import cwe

BaseParser().register_resource(cwe.CWE, db_connection_str=args.cache_file)
if args.csa_ccm_v4_in:
from application.utils.external_project_parsers.parsers import ccmv4

BaseParser().register_resource(
ccmv4.CloudControlsMatrix, db_connection_str=args.cache_file
)
if args.iso_27001_in:
from application.utils.external_project_parsers.parsers import iso27001

BaseParser().register_resource(
iso27001.ISO27001, db_connection_str=args.cache_file
)
if args.owasp_secure_headers_in:
from application.utils.external_project_parsers.parsers import secure_headers

BaseParser().register_resource(
secure_headers.SecureHeaders, db_connection_str=args.cache_file
)
if args.pci_dss_4_in:
from application.utils.external_project_parsers.parsers import pci_dss

BaseParser().register_resource(
pci_dss.PciDss, db_connection_str=args.cache_file
)
if args.juiceshop_in:
from application.utils.external_project_parsers.parsers import juiceshop

BaseParser().register_resource(
juiceshop.JuiceShop, db_connection_str=args.cache_file
)
if args.dsomm_in:
from application.utils.external_project_parsers.parsers import dsomm

BaseParser().register_resource(dsomm.DSOMM, db_connection_str=args.cache_file)
if args.cloud_native_security_controls_in:
from application.utils.external_project_parsers.parsers import cloud_native_security_controls
from application.utils.external_project_parsers.parsers import (
cloud_native_security_controls,
)

BaseParser().register_resource(
cloud_native_security_controls.CloudNativeSecurityControls,
db_connection_str=args.cache_file,
Expand Down
3 changes: 2 additions & 1 deletion application/utils/gap_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,15 @@ def get_next_id(step, previous_id):

# database is of type Node_collection, cannot annotate due to circular import
def schedule(standards: List[str], database):
conn = redis.connect()
standards_hash = make_resources_key(standards)
if database.gap_analysis_exists(
standards_hash
): # easiest, it's been calculated and cached, get it from the db
return flask_json.loads(database.get_gap_analysis_result(standards_hash))

logger.info(f"Gap analysis result for {standards_hash} does not exist")

conn = redis.connect()
gap_analysis_results = conn.get(standards_hash)
if (
gap_analysis_results
Expand Down
3 changes: 1 addition & 2 deletions application/web/web_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from typing import Any
from application.utils import oscal_utils, redis

from rq import Queue, job, exceptions
from rq import job, exceptions

from application.database import db
from application.defs import cre_defs as defs
Expand All @@ -23,7 +23,6 @@
from flask import (
Blueprint,
abort,
current_app,
jsonify,
redirect,
request,
Expand Down

0 comments on commit d879ac9

Please sign in to comment.