Skip to content

Commit 39b5886

Browse files
[CDAPI-55]: Minor sonar fixes
1 parent 28fc00e commit 39b5886

4 files changed

Lines changed: 10 additions & 2 deletions

File tree

infrastructure/images/api-gateway-mock/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ FROM $url
77
COPY resources/ /resources
88
WORKDIR /resources
99

10-
RUN pip install --no-cache-dir -r requirements.txt
10+
RUN pip install --no-cache-dir -r requirements.txt \
11+
&& addgroup -S nonroot \
12+
&& adduser -S flask -G nonroot
13+
14+
USER flask
1115

1216
ENTRYPOINT ["flask", "--app", "server", "run", "--host=0.0.0.0"]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
flask==3.1.2
2+
flask-cors==6.0.2
23
requests==2.32.5

infrastructure/images/api-gateway-mock/resources/server.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import requests
44
from flask import Flask, request
5+
from flask_cors import CORS
56

67
# Very simple logging configuration taken from https://flask.palletsprojects.com/en/stable/logging/
78
dictConfig(
@@ -24,6 +25,7 @@
2425
)
2526

2627
app = Flask(__name__)
28+
cors = CORS(app, resources={r"/*": {"origins": "http://localhost:5002"}})
2729

2830

2931
@app.route("/", methods=["POST", "GET"], defaults={"path_params": None})
@@ -32,6 +34,7 @@ def forward_request(path_params):
3234
app.logger.info("received request with data: %s", request.get_data(as_text=True))
3335

3436
response = requests.post(
37+
# NOSONAR python:S5332 - Only HTTP is supported by local lambda container.
3538
"http://pathology-api:8080/2015-03-31/functions/function/invocations",
3639
json={
3740
"body": request.get_data(as_text=True).replace("\n", "").replace(" ", ""),

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ sonar.exclusions=docs/**,pathology-api/test-artefacts/**,pathology-api/coverage-
1313
sonar.tests=pathology-api
1414
sonar.test.inclusions=pathology-api/**/test_*.py, pathology-api/tests/**
1515

16-
sonar.coverage.exclusions=**/tests/**,**/features/**,**/test_*.py
16+
sonar.coverage.exclusions=**/tests/**,**/features/**,**/test_*.py,infrastructure/images/api-gateway-mock/resources/**
1717
# Set Python version for more precise analysis
1818
sonar.python.version=3.14

0 commit comments

Comments
 (0)