Skip to content

Conversation

EtienneM
Copy link
Member

No description provided.

@EtienneM EtienneM self-assigned this Aug 29, 2025
Copy link

mkdir -p ${bin_dir}
mkdir -p "${PREFIX}/var/blackfire/run"
mkdir -p "${PREFIX}/etc/blackfire"
echo -e "[blackfire]\nserver-id=f1abf3a8-3f85-4743-99b2-97f066c099b9\nserver-token=5ecbc6486e9db6b780a0c0a9ef1e244709e632996fe9105cb9075ab2826944d5" > "${PREFIX}/etc/blackfire/agent.ini"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semgrep identified an issue in your code:
A gitleaks generic-api-key was detected which attempts to identify hard-coded credentials. It is not recommended to store credentials in source-code, as this risks secrets being leaked and used by either an internal or external malicious adversary. It is recommended to use environment variables to securely provide credentials or retrieve credentials from a secure vault or HSM (Hardware Security Module). This rule can introduce a lot of false positives, it is not recommended to be used in PR comments.

To resolve this comment:

✨ Commit Assistant fix suggestion

Suggested change
echo -e "[blackfire]\nserver-id=f1abf3a8-3f85-4743-99b2-97f066c099b9\nserver-token=5ecbc6486e9db6b780a0c0a9ef1e244709e632996fe9105cb9075ab2826944d5" > "${PREFIX}/etc/blackfire/agent.ini"
# Read Blackfire credentials from environment variables for secure configuration
server_id="${BLACKFIRE_SERVER_ID}"
server_token="${BLACKFIRE_SERVER_TOKEN}"
# Warn if variables are not set (optional but recommended for usability)
if [[ -z "$server_id" || -z "$server_token" ]]; then
echo "ERROR: BLACKFIRE_SERVER_ID and BLACKFIRE_SERVER_TOKEN environment variables must be set" >&2
exit 1
fi
echo -e "[blackfire]\nserver-id=${server_id}\nserver-token=${server_token}" > "${PREFIX}/etc/blackfire/agent.ini"
View step-by-step instructions
  1. Remove the hard-coded server-id and server-token from the script. Replace them with placeholders like {{BLACKFIRE_SERVER_ID}} and {{BLACKFIRE_SERVER_TOKEN}}.
  2. Modify the script to read these values from environment variables. You can do this by using shell parameter expansion: server-id=${BLACKFIRE_SERVER_ID} and server-token=${BLACKFIRE_SERVER_TOKEN}.
  3. Update the line that writes to agent.ini to use these variables:
    echo -e "[blackfire]\nserver-id=${server-id}\nserver-token=${server-token}" > ${PREFIX}/etc/blackfire/agent.ini
  4. Ensure that the environment variables BLACKFIRE_SERVER_ID and BLACKFIRE_SERVER_TOKEN are set in the environment where this script runs. This can be done by exporting them in the shell or setting them in a configuration file that is sourced before running the script.

This approach ensures that sensitive information is not stored directly in the source code, reducing the risk of accidental exposure.

💬 Ignore this finding

Reply with Semgrep commands to ignore this finding.

  • /fp <comment> for false positive
  • /ar <comment> for acceptable risk
  • /other <comment> for all other reasons

Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by generic-api-key.

You can view more details about this finding in the Semgrep AppSec Platform.

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