Castlenine / svelte-qrcode

QR Code generator for Svelte & SvelteKit, with no dependencies
MIT License
20 stars 3 forks source link

Improve error callback #2

Closed eliandoran closed 1 month ago

eliandoran commented 4 months ago

Hi there,

I was trying to use this component to generate a QR code based on user input. When the QR code is too large, there is an exception that is logged only in the console. Trying to hook into the qrCodeGenerationFailed event did not seem to work so I looked a bit into it.

I started by creating a simple test that I added in the demo page.

image

I researched a bit and the problem appears to be that we are generating the QR code without logo in the component initialization phase, and apparently dispatching events from this state is not possible (see https://github.com/sveltejs/svelte/issues/4470 and https://github.com/sveltejs/svelte/issues/6106).

Two possible solutions: move QR code generation in onMount (just like the version with logo), or store the error and dispatch it later. In order to not affect too much the code base, I chose the second option.

In addition, I've passed the error as an argument to the event, so that the error can potentially be parsed or displayed to the user programatically.

gitguardian[bot] commented 4 months ago

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

Since your pull request originates from a forked repository, GitGuardian is not able to associate the secrets uncovered with secret incidents on your GitGuardian dashboard. Skipping this check run and merging your pull request will create secret incidents on your GitGuardian dashboard.

🔎 Detected hardcoded secret in your pull request
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | | | -------------- | ------------------ | ------------------------------ | ---------------- | --------------- | -------------------- | | [10602387](https://dashboard.gitguardian.com/workspace/105543/incidents/10602387) | Triggered | Generic High Entropy Secret | f7041a72aee50e479321a70998d12e54464d6e3f | src/routes/+page.svelte | [View secret](https://github.com/Castlenine/svelte-qrcode/commit/f7041a72aee50e479321a70998d12e54464d6e3f#diff-1e1270da740e81dd13f8a65057582b0fce8a5fb3817ef913f3e90d7f82c4e9dfR398) |
🛠 Guidelines to remediate hardcoded secrets
1. Understand the implications of revoking this secret by investigating where it is used in your code. 2. Replace and store your secret safely. [Learn here](https://blog.gitguardian.com/secrets-api-management?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment) the best practices. 3. Revoke and [rotate this secret](https://docs.gitguardian.com/secrets-detection/secrets-detection-engine/detectors/generics/generic_high_entropy_secret#revoke-the-secret?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment). 4. If possible, [rewrite git history](https://blog.gitguardian.com/rewriting-git-history-cheatsheet?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment). Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data. To avoid such incidents in the future consider - following these [best practices](https://blog.gitguardian.com/secrets-api-management/?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment) for managing and storing secrets including API keys and other credentials - install [secret detection on pre-commit](https://docs.gitguardian.com/ggshield-docs/integrations/git-hooks/pre-commit?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment) to catch secret before it leaves your machine and ease remediation.

🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Castlenine commented 1 month ago

Thank you for your good work.