Skip to content

Commit 81c603d

Browse files
authored
Merge pull request #160 from abnamro/2412943-resc-liveness-and-readiness-probe
2412943 resc liveness and readiness probe
2 parents f646cef + e3aa84e commit 81c603d

File tree

17 files changed

+4510
-37
lines changed

17 files changed

+4510
-37
lines changed

.github/workflows/k8-infra-ci.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ jobs:
104104
cd ${{ env.KUBERNETES_INFRA_DIR }}
105105
# Running temporary exit code 0 till all the issues are fixed
106106
datree config set offline local
107-
datree test resc_helm_template.yaml --only-k8s-files --no-record --verbose --only-k8s-files --policy-config datree-policies.yaml || exit 0
107+
datree test resc_helm_template.yaml --only-k8s-files --no-record --verbose --policy-config datree-policies.yaml
108108
109109
release-charts:
110110
name: Release Charts

components/resc-backend/src/resc_backend/resc_web_service/api.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def generate_logger_config(log_file_path, debug=True):
116116
description="RESC API helps you to perform several operations upon findings "
117117
"obtained from multiple source code repositories.",
118118
version=get_package_version(),
119-
openapi_tags=tags_metadata, dependencies=AUTH)
119+
openapi_tags=tags_metadata)
120120

121121
if env_variables[ENABLE_CORS].lower() in ["true"]:
122122
origins = env_variables[CORS_ALLOWED_DOMAINS].split(', ')
@@ -129,15 +129,15 @@ def generate_logger_config(log_file_path, debug=True):
129129
)
130130

131131
app.include_router(health.router, prefix=RWS_VERSION_PREFIX)
132-
app.include_router(common.router, prefix=RWS_VERSION_PREFIX)
133-
app.include_router(rules.router, prefix=RWS_VERSION_PREFIX)
134-
app.include_router(rule_packs.router, prefix=RWS_VERSION_PREFIX)
135-
app.include_router(findings.router, prefix=RWS_VERSION_PREFIX)
136-
app.include_router(detailed_findings.router, prefix=RWS_VERSION_PREFIX)
137-
app.include_router(repositories.router, prefix=RWS_VERSION_PREFIX)
138-
app.include_router(scans.router, prefix=RWS_VERSION_PREFIX)
139-
app.include_router(vcs_instances.router, prefix=RWS_VERSION_PREFIX)
140-
app.include_router(metrics.router, prefix=RWS_VERSION_PREFIX)
132+
app.include_router(common.router, prefix=RWS_VERSION_PREFIX, dependencies=AUTH)
133+
app.include_router(rules.router, prefix=RWS_VERSION_PREFIX, dependencies=AUTH)
134+
app.include_router(rule_packs.router, prefix=RWS_VERSION_PREFIX, dependencies=AUTH)
135+
app.include_router(findings.router, prefix=RWS_VERSION_PREFIX, dependencies=AUTH)
136+
app.include_router(detailed_findings.router, prefix=RWS_VERSION_PREFIX, dependencies=AUTH)
137+
app.include_router(repositories.router, prefix=RWS_VERSION_PREFIX, dependencies=AUTH)
138+
app.include_router(scans.router, prefix=RWS_VERSION_PREFIX, dependencies=AUTH)
139+
app.include_router(vcs_instances.router, prefix=RWS_VERSION_PREFIX, dependencies=AUTH)
140+
app.include_router(metrics.router, prefix=RWS_VERSION_PREFIX, dependencies=AUTH)
141141

142142
# Apply the security headers to the app in the form of middleware
143143
app.middleware("http")(add_security_headers)

components/resc-vcs-scanner/src/vcs_scanner/secret_scanners/celery_worker.py

+14-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# pylint: disable=E1101
1+
# pylint: disable=E1101,W0603
22
# Standard Library
33
import json
44
import os
@@ -46,22 +46,29 @@
4646
rws_url = f"http://{env_variables[RESC_API_NO_AUTH_SERVICE_HOST]}:{env_variables[RESC_API_NO_AUTH_SERVICE_PORT]}"
4747
rws_writer: RESTAPIWriter = RESTAPIWriter(rws_url=rws_url)
4848

49-
vcs_instances_list = load_vcs_instances(env_variables[VCS_INSTANCES_FILE_PATH])
50-
vcs_instances = rws_writer.write_vcs_instances(vcs_instances_list)
51-
52-
downloaded_rule_pack_version = rws_writer.download_rule_pack()
49+
VCS_INSTANCES_LIST = None
50+
VCS_INSTANCES = None
51+
DOWNLOADED_RULE_PACK_VERSION = None
5352

5453

5554
@app.task(name="scan_repository", Queue=rabbitmq_queue)
5655
def scan_repository(repository):
57-
active_rule_pack_version = rws_writer.check_active_rule_pack_version(rule_pack_version=downloaded_rule_pack_version)
56+
global VCS_INSTANCES_LIST, VCS_INSTANCES, DOWNLOADED_RULE_PACK_VERSION
57+
if not VCS_INSTANCES_LIST:
58+
VCS_INSTANCES_LIST = load_vcs_instances(env_variables[VCS_INSTANCES_FILE_PATH])
59+
if not VCS_INSTANCES:
60+
VCS_INSTANCES = rws_writer.write_vcs_instances(VCS_INSTANCES_LIST)
61+
if not DOWNLOADED_RULE_PACK_VERSION:
62+
DOWNLOADED_RULE_PACK_VERSION = rws_writer.download_rule_pack()
63+
64+
active_rule_pack_version = rws_writer.check_active_rule_pack_version(rule_pack_version=DOWNLOADED_RULE_PACK_VERSION)
5865

5966
repository_runtime = RepositoryRuntime(**json.loads(repository))
6067

6168
logger.info(f"Received repository to scan via the queue '{rabbitmq_queue}' => "
6269
f"{repository_runtime.project_key}/{repository_runtime.repository_name}")
6370
try:
64-
vcs_instance = vcs_instances[repository_runtime.vcs_instance_name]
71+
vcs_instance = VCS_INSTANCES[repository_runtime.vcs_instance_name]
6572

6673
repository = Repository(project_key=repository_runtime.project_key,
6774
repository_id=repository_runtime.repository_id,

0 commit comments

Comments
 (0)