Skip to content

Conversation

@Vlasis-Perdikidis
Copy link
Contributor

Description

Context

Type of changes

  • Refactoring (non-breaking change)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would change existing functionality)
  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I am familiar with the contributing guidelines
  • I have followed the code style of the project
  • I have added tests to cover my changes
  • I have updated the documentation accordingly
  • This PR is a result of pair or mob programming
  • If I have used the 'skip-trivy-package' label I have done so responsibly and in the knowledge that this is being fixed as part of a separate ticket/PR.

Sensitive Information Declaration

To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.

  • I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.

@Vlasis-Perdikidis Vlasis-Perdikidis requested a review from a team as a code owner January 20, 2026 12:59
@Vlasis-Perdikidis Vlasis-Perdikidis changed the title change to create a PR Expose key metrics to cloudwatch Jan 20, 2026
@Vlasis-Perdikidis Vlasis-Perdikidis requested review from a team as code owners January 21, 2026 15:27
return async (event: SQSEvent) => {
console.log(
"the environment variables:",
JSON.stringify(process.env, null, 2),

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

This logs sensitive data returned by
process environment
as clear text.

Copilot Autofix

AI 1 day ago

In general, the way to fix this is to stop logging sensitive data directly. For environment variables, you should never serialize and log the entire process.env. If you need diagnostics, log only specific, non-sensitive keys (e.g., feature flags) and avoid values that may contain credentials, tokens, or personal data.

For this specific code, the minimal fix without changing functionality elsewhere is to remove (or, if absolutely necessary, severely limit) the logging of process.env. Since the handler already logs the SQSEvent and other diagnostic information, the environment dump is not essential for normal operation. The safest and simplest solution is to delete the console.log statement that prints "the environment variables:" along with JSON.stringify(process.env, null, 2). If you still want some indication of environment configuration without leaking secrets, you could replace it with a log that only records the names of environment variables or a static message stating that the handler has started; however, because we cannot reliably know which env vars are safe, the most secure approach in this snippet is to remove the environment logging entirely.

Concretely, in lambdas/upsert-letter/src/handler/upsert-handler.ts:

  • Remove lines 159–162 that log "the environment variables:" and process.env.
  • No new imports or helper methods are required.
Suggested changeset 1
lambdas/upsert-letter/src/handler/upsert-handler.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/lambdas/upsert-letter/src/handler/upsert-handler.ts b/lambdas/upsert-letter/src/handler/upsert-handler.ts
--- a/lambdas/upsert-letter/src/handler/upsert-handler.ts
+++ b/lambdas/upsert-letter/src/handler/upsert-handler.ts
@@ -156,10 +156,6 @@
 export default function createUpsertLetterHandler(deps: Deps): SQSHandler {
   return metricScope((metrics) => {
     return async (event: SQSEvent) => {
-      console.log(
-        "the environment variables:",
-        JSON.stringify(process.env, null, 2),
-      );
       console.log("The SQSEvent:", event);
       const batchItemFailures: SQSBatchItemFailure[] = [];
       metrics.setNamespace("vlasis_upsertLetter");
EOF
@@ -156,10 +156,6 @@
export default function createUpsertLetterHandler(deps: Deps): SQSHandler {
return metricScope((metrics) => {
return async (event: SQSEvent) => {
console.log(
"the environment variables:",
JSON.stringify(process.env, null, 2),
);
console.log("The SQSEvent:", event);
const batchItemFailures: SQSBatchItemFailure[] = [];
metrics.setNamespace("vlasis_upsertLetter");
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant