Skip to content

Potential fix for code scanning alert no. 2: Hard-coded cryptographic value#191

Draft
arielsrv wants to merge 1 commit into
masterfrom
alert-autofix-2
Draft

Potential fix for code scanning alert no. 2: Hard-coded cryptographic value#191
arielsrv wants to merge 1 commit into
masterfrom
alert-autofix-2

Conversation

@arielsrv
Copy link
Copy Markdown
Owner

Potential fix for https://github.com/arielsrv/rustapi/security/code-scanning/2

General fix: remove hard-coded password literals and generate per-call test passwords dynamically (or inject them via parameters/env), then hash as before.

Best minimal fix without changing existing functionality: in src/tests/utils.rs, replace the hard-coded "Password1" with a generated password string derived from randomness/time so each created user gets a non-hardcoded credential while preserving the same flow (hash_passwordUser::newUser::create). Since we can only edit shown code and should avoid broad refactors, update create_user locally by generating a password at runtime (e.g., with SystemTime nanos), then pass it to hash_password.

Needed changes:

  • In src/tests/utils.rs, add use std::time::{SystemTime, UNIX_EPOCH};.
  • In create_user, replace let password = "Password1"; with runtime-generated String.
  • Keep all existing behavior otherwise unchanged.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

… value

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 15, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bc2b9d3a-f21f-4ee3-a938-d6505932b321

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch alert-autofix-2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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