Conversation
Co-authored-by: DeepExtrema <175066046+DeepExtrema@users.noreply.github.com>
|
|
||
| // Simple password hashing (use bcrypt in production) | ||
| function hashPassword(password: string): string { | ||
| return crypto.createHash('sha256').update(password).digest('hex'); |
Check failure
Code scanning / CodeQL
Use of password hash with insufficient computational effort High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
The best way to fix this issue is to replace the usage of the generic SHA-256 hash with a secure password hashing algorithm, such as bcrypt. Bcrypt is purpose-built for password hashing, featuring built-in salting and slow, computationally expensive hashing.
To implement the fix:
- Add the required import for the
bcryptlibrary at the top of the file. - Replace the
hashPasswordfunction implementation to usebcrypt.hashSync(password, saltRounds), where a reasonably highsaltRoundsvalue is set (such as 10). - No changes are needed to the rest of the code as the function interface remains the same.
- The rest of the seed script will now generate bcrypt password hashes, which are much more secure.
Suggested changeset
2
scripts/seed-test-env.ts
| @@ -8,7 +8,7 @@ | ||
| */ | ||
|
|
||
| import { MongoClient } from 'mongodb'; | ||
| import * as crypto from 'crypto'; | ||
| import * as bcrypt from 'bcrypt'; | ||
|
|
||
| interface User { | ||
| _id?: string; | ||
| @@ -32,9 +32,10 @@ | ||
| const MONGO_URL = process.env.MONGO_URL || 'mongodb://testuser:testpass@localhost:27017'; | ||
| const DB_NAME = process.env.MONGO_DB_NAME || 'sherlock_test'; | ||
|
|
||
| // Simple password hashing (use bcrypt in production) | ||
| // Secure password hashing using bcrypt | ||
| const SALT_ROUNDS = 10; | ||
| function hashPassword(password: string): string { | ||
| return crypto.createHash('sha256').update(password).digest('hex'); | ||
| return bcrypt.hashSync(password, SALT_ROUNDS); | ||
| } | ||
|
|
||
| async function seedUsers(db: any): Promise<void> { |
package.json
Outside changed files
| @@ -24,6 +24,7 @@ | ||
| "@vitest/coverage-v8": "^1.1.0" | ||
| }, | ||
| "dependencies": { | ||
| "lucide-react": "^0.537.0" | ||
| "lucide-react": "^0.537.0", | ||
| "bcrypt": "^6.0.0" | ||
| } | ||
| } |
This fix introduces these dependencies
| Package | Version | Security advisories |
| bcrypt (npm) | 6.0.0 | None |
Copilot is powered by AI and may make mistakes. Always verify output.
Co-authored-by: DeepExtrema <175066046+DeepExtrema@users.noreply.github.com>
Co-authored-by: DeepExtrema <175066046+DeepExtrema@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add docker-compose and test environment setup
Add A4 Env & Seed Harness: Complete Testing Infrastructure with Docker Compose, Testcontainers, and Idempotent Seeder
Oct 13, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR delivers a comprehensive testing environment and seed harness for the Sherlock project, providing all infrastructure needed to run tests locally and in CI with minimal setup.
What's Included
🐳 Docker Compose CI Environment (
docker-compose.ci.yml)Provides containerized test dependencies with health checks and optimized configuration:
All services use tmpfs for fast I/O and include health checks to ensure readiness before tests run.
🌱 Idempotent Test Seeder (
scripts/seed-test-env.ts)TypeScript-based seeder that populates test data safely and repeatably:
Key Features:
🧪 Testcontainers Configuration (
tests/testcontainers.config.ts)Provides isolated container environments for integration tests:
📚 Comprehensive Documentation (
docs/testing-env.md)Complete 6.8KB guide covering:
⚙️ npm Scripts
Added convenient commands for test management:
Testing & Validation
All components have been thoroughly tested:
Design Principles
Usage Example
Files Added
docker-compose.ci.yml- Test services configurationtsconfig.json- TypeScript configurationvitest.config.ts- Integration test configurationplaywright.config.ts- E2E test configurationscripts/seed-test-env.ts- Idempotent test data seederscripts/README.md- Scripts documentationtests/testcontainers.config.ts- Testcontainers utilitytests/integration/sample.test.ts- Sample integration testtests/e2e/sample.spec.ts- Sample E2E testtests/README.md- Test structure guidedocs/testing-env.md- Complete testing documentation.gitignore- Test artifacts exclusionDependencies Added
@playwright/test- E2E browser testingvitest+@vitest/coverage-v8- Fast integration testingtestcontainers- Isolated test containersmongodb- MongoDB client for seedingtsx- TypeScript executiontypescript+@types/node- TypeScript supportThis infrastructure is ready for immediate use and provides a solid foundation for expanding test coverage. 🚀
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
4.0.18.172.in-addr.arpajava -cp /usr/share/java/cp-base-new/* -Dlog4j.configuration=file:/etc/kafka/log4j.properties io.confluent.admin.utils.cli.ZookeeperReadyCommand zookeeper-test:2181 40000(dns block)compass.mongodb.commongosh mongodb://127.0.0.1:27017/admin?directConne(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.