> ## Documentation Index
> Fetch the complete documentation index at: https://docs.khanhng.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 2.7 Risks and Technical Debt

> Risks and Technical Debt for ReportGeneratorTool.

### 2.7.1 Risks

| ID | Risk | Probability | Potential impact | Priority | Mitigation |
| - | - | - | - | - | - |
| R-001 | Credentials present in the repository could be used to access storage or email services. The exposure is confirmed; misuse is not established. | Not assessed | High | Pending assessment | Rotate and invalidate exposed credentials, remove them from current artifacts and history, and add secret scanning. |
| R-002 | If the deployed HTTP route lacks an effective access boundary, an unauthorized caller could start a report and cause portal credentials to be processed. Deployed access settings have not been verified. | Not assessed | High | Pending assessment | Define the caller authorization policy and test accepted and rejected requests in the deployed environment. |
| R-003 | A change to the external portal’s selectors, authentication flow, CSV format, or chart could stop report generation or produce incorrect content. | Not assessed | High | Pending assessment | Add representative end-to-end checks, validate the CSV schema, and report the failed portal step clearly. |
| R-004 | A Blob Storage or email-provider failure could prevent the PDF handoff or delivery. Current orchestration error handling may obscure the terminal result. | Not assessed | High | Pending assessment | Define retry and terminal-failure behavior, test dependency failures, and alert on failed runs. |
| R-005 | Concurrent Chromium processes or retained temporary files could exhaust host memory or disk space. | Not assessed | High | Pending assessment | Bound concurrency from measured load tests and guarantee browser and file cleanup after success and failure. |
| R-006 | The PDF template loads a public CSS asset. If that asset is unavailable, report appearance may differ from the intended design. | Not assessed | Medium | Pending assessment | Bundle required styling or verify the rendered PDF without external network access. |

R-001 is supported by the [Dockerfile](https://github.com/TQKNG/automation/blob/27045ec413f88cd2227ab08e18ec76db3e8e3d34/Dockerfile); do not reproduce credential values in documentation.\
R-002 is based on the [HTTP trigger](https://github.com/TQKNG/automation/blob/27045ec413f88cd2227ab08e18ec76db3e8e3d34/src/functions/orchestrator_reporting.js), which does not show an application-level authorization check.\
R-003 and R-005 are supported by the [report service](https://github.com/TQKNG/automation/blob/27045ec413f88cd2227ab08e18ec76db3e8e3d34/src/functions/shared/utils/reportService.js).\
R-004 is supported by the [orchestrator](https://github.com/TQKNG/automation/blob/27045ec413f88cd2227ab08e18ec76db3e8e3d34/src/functions/orchestrator_reporting.js) and [email activity](https://github.com/TQKNG/automation/blob/27045ec413f88cd2227ab08e18ec76db3e8e3d34/src/functions/activity_sendEmail.js).\
R-006 is supported by the [report template](https://github.com/TQKNG/automation/blob/27045ec413f88cd2227ab08e18ec76db3e8e3d34/src/functions/shared/utils/reportTemplateService.js).

### 2.7.2 Technical Debt

| ID | Technical debt | Affected building block in Section 2.1 | Evidence and consequence |
| - | - | - | - |
| TD-001 | Credentials are embedded in a committed deployment artifact. | Azure Function App deployment | The [Dockerfile](https://github.com/TQKNG/automation/blob/27045ec413f88cd2227ab08e18ec76db3e8e3d34/Dockerfile) contains sensitive configuration. Rotation and removal are required even if the file is later edited. |
| TD-002 | Request and activity inputs are logged without redaction. | HTTP Trigger, Report Orchestrator, Generate Report Activity | The [orchestrator](https://github.com/TQKNG/automation/blob/27045ec413f88cd2227ab08e18ec76db3e8e3d34/src/functions/orchestrator_reporting.js) and [activity](https://github.com/TQKNG/automation/blob/27045ec413f88cd2227ab08e18ec76db3e8e3d34/src/functions/activity_generateReport.js) log input that can include portal credentials and recipients. |
| TD-003 | The orchestrator catches errors without rethrowing them. | Report Orchestrator | The [catch block](https://github.com/TQKNG/automation/blob/27045ec413f88cd2227ab08e18ec76db3e8e3d34/src/functions/orchestrator_reporting.js) logs the message but does not preserve an explicit failed orchestration result. |
| TD-004 | Automated tests are absent. | Azure Function App and all components | The [test script](https://github.com/TQKNG/automation/blob/27045ec413f88cd2227ab08e18ec76db3e8e3d34/package.json) reports that no tests exist. |
| TD-005 | The request accepts a devices array, but report generation uses only its first item. | Report Service | The [report service](https://github.com/TQKNG/automation/blob/27045ec413f88cd2227ab08e18ec76db3e8e3d34/src/functions/shared/utils/reportService.js) uses `devices[0]`; additional devices can be omitted without rejection. |
| TD-006 | CSV rows are split on commas without a CSV parser or schema validation. | CSV Processor | The [CSV processor](https://github.com/TQKNG/automation/blob/27045ec413f88cd2227ab08e18ec76db3e8e3d34/src/functions/shared/utils/processCSVService.js) can misread quoted commas or unexpected columns. |
| TD-007 | The displayed compliance label is fixed text, and alarm counts are counts of threshold-matching readings. | CSV Processor, Report Template Service | The [template](https://github.com/TQKNG/automation/blob/27045ec413f88cd2227ab08e18ec76db3e8e3d34/src/functions/shared/utils/reportTemplateService.js) always displays “Compliant.” The [CSV processor](https://github.com/TQKNG/automation/blob/27045ec413f88cd2227ab08e18ec76db3e8e3d34/src/functions/shared/utils/processCSVService.js) increments alarm counts for each matching reading. Neither behavior establishes distinct alarm events or a calculated compliance result. |
| TD-008 | Browser and temporary-file cleanup is not guaranteed after failure. | Report Service, Email Service | The [report service](https://github.com/TQKNG/automation/blob/27045ec413f88cd2227ab08e18ec76db3e8e3d34/src/functions/shared/utils/reportService.js) closes the browser only on the success path, and cleanup in the [email service](https://github.com/TQKNG/automation/blob/27045ec413f88cd2227ab08e18ec76db3e8e3d34/src/functions/shared/utils/sendEmailService.js) is commented out. |
| TD-009 | Deployment artifacts describe different runtime paths. | Azure Function App deployment | The [Dockerfile](https://github.com/TQKNG/automation/blob/27045ec413f88cd2227ab08e18ec76db3e8e3d34/Dockerfile) uses a Node.js 20 Azure Functions image, while the [GitHub workflow](https://github.com/TQKNG/automation/blob/27045ec413f88cd2227ab08e18ec76db3e8e3d34/.github/workflows/main_reportauto.yml) packages a Node.js 22 Function App deployment. The authoritative production path is not identified in the repository. |

### 2.7.3 Remediation order

1. Rotate exposed credentials and remove them from deployment artifacts.
2. Establish caller authorization and redact request logging.
3. Make orchestration failures explicit and add a representative end-to-end test.
4. Decide whether reports support multiple devices and define the meaning of an alarm and “Compliant.”
5. Validate CSV input and guarantee browser and temporary-file cleanup.
6. Identify the authoritative deployment path and test the chosen package under load.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.