saladenicoise / SOEN-487-Galactus

Final Project for SOEN 487
4 stars 1 forks source link

Adding a rabbit producer and consumer to the API #49

Closed kkodmani closed 1 year ago

kkodmani commented 1 year ago

Adding a producer and consumer the geo location and weather retrieval services. I also added a fix where entering the wrong city crashes the server.

gitguardian[bot] commented 1 year ago

⚠️ GitGuardian has uncovered 9 secrets 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.

🔎 Detected hardcoded secrets in your pull request
| GitGuardian id | Secret | Commit | Filename | | | -------------- | ------------------------- | ---------------- | --------------- | -------------------- | | [6171532](https://dashboard.gitguardian.com/incidents/6171532?occurrence=89287695) | AMQP Credentials | d57b5ed4b4995d637c71f75064239d289df4bfec | data-demon/consumer.js | [View secret](https://github.com/saladenicoise/SOEN-487-Galactus/commit/d57b5ed4b4995d637c71f75064239d289df4bfec#diff-fd6cee2c40771f956e01ecb280e982990b9e10290e3a40e1cff8c9d449e4dcd7R3) | | [6171532](https://dashboard.gitguardian.com/incidents/6171532?occurrence=89287696) | AMQP Credentials | d57b5ed4b4995d637c71f75064239d289df4bfec | data-demon/producer.js | [View secret](https://github.com/saladenicoise/SOEN-487-Galactus/commit/d57b5ed4b4995d637c71f75064239d289df4bfec#diff-1dc9a1e3d01eb8507c47927855ef622ce976ef9e519c1f16bf35301215d54a62R3) | | [6171532](https://dashboard.gitguardian.com/incidents/6171532?occurrence=89358706) | AMQP Credentials | 72616774da18c0dc5aff78e8ff9d3ae027a9c0aa | data-demon/producer.js | [View secret](https://github.com/saladenicoise/SOEN-487-Galactus/commit/72616774da18c0dc5aff78e8ff9d3ae027a9c0aa#diff-1dc9a1e3d01eb8507c47927855ef622ce976ef9e519c1f16bf35301215d54a62R3) | | [6171532](https://dashboard.gitguardian.com/incidents/6171532?occurrence=89358707) | AMQP Credentials | 72616774da18c0dc5aff78e8ff9d3ae027a9c0aa | data-demon/consumer.js | [View secret](https://github.com/saladenicoise/SOEN-487-Galactus/commit/72616774da18c0dc5aff78e8ff9d3ae027a9c0aa#diff-fd6cee2c40771f956e01ecb280e982990b9e10290e3a40e1cff8c9d449e4dcd7R3) | | [6171532](https://dashboard.gitguardian.com/incidents/6171532?occurrence=89359554) | AMQP Credentials | dcd625cd8b836aa33aae66407ca70ddb49b4968c | data-demon/producer.js | [View secret](https://github.com/saladenicoise/SOEN-487-Galactus/commit/dcd625cd8b836aa33aae66407ca70ddb49b4968c#diff-1dc9a1e3d01eb8507c47927855ef622ce976ef9e519c1f16bf35301215d54a62R3) | | [6171532](https://dashboard.gitguardian.com/incidents/6171532?occurrence=89359555) | AMQP Credentials | dcd625cd8b836aa33aae66407ca70ddb49b4968c | data-demon/consumer.js | [View secret](https://github.com/saladenicoise/SOEN-487-Galactus/commit/dcd625cd8b836aa33aae66407ca70ddb49b4968c#diff-fd6cee2c40771f956e01ecb280e982990b9e10290e3a40e1cff8c9d449e4dcd7R3) | | [6171533](https://dashboard.gitguardian.com/incidents/6171533?occurrence=89287694) | OpenWeatherMap Token | d57b5ed4b4995d637c71f75064239d289df4bfec | data-demon/server.js | [View secret](https://github.com/saladenicoise/SOEN-487-Galactus/commit/d57b5ed4b4995d637c71f75064239d289df4bfec#diff-ef0fb2e7fb25651e225804a30d658682047766bc866a1428d066ec3ade69b60cR5) | | [6171533](https://dashboard.gitguardian.com/incidents/6171533?occurrence=89358723) | OpenWeatherMap Token | 2bd7df50036dbfffbee94cedcdaf918f8aad1d9e | data-demon/server.js | [View secret](https://github.com/saladenicoise/SOEN-487-Galactus/commit/2bd7df50036dbfffbee94cedcdaf918f8aad1d9e#diff-ef0fb2e7fb25651e225804a30d658682047766bc866a1428d066ec3ade69b60cR16) | | [6171533](https://dashboard.gitguardian.com/incidents/6171533?occurrence=89358767) | OpenWeatherMap Token | 3c7a7aa64fccb19ae86131765b1c69f66adc9f8e | data-demon/server.js | [View secret](https://github.com/saladenicoise/SOEN-487-Galactus/commit/3c7a7aa64fccb19ae86131765b1c69f66adc9f8e#diff-ef0fb2e7fb25651e225804a30d658682047766bc866a1428d066ec3ade69b60cL16) |
🛠 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 secrets 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 these secrets](https://docs.gitguardian.com/secrets-detection/detectors/specifics/amqp_uri#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://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.

Our GitHub checks need improvements? Share your feedbacks!

eyeshield2110 commented 1 year ago

Gonna review and run the code tonight. Does your PR contain everything needed to run it? (Aka no missing api keys for your cloud rabbit instance)?

kkodmani commented 1 year ago

Gonna review and run the code tonight. Does your PR contain everything needed to run it? (Aka no missing api keys for your cloud rabbit instance)?

No missing API keys as they are out in the open in the file right now. All you do need is to the missing dependency that is added in the package json.

You can simulate by 1) Opening two terminals one for the usual server at 3000 2) The other as node ./consumer (This terminal will consume anything that you feed into the the first terminal).

eyeshield2110 commented 1 year ago

You can simulate by

1) Opening two terminals one for the usual server at 3000

2) The other as node ./consumer (This terminal will consume anything that you feed into the the first terminal).

Is the producer/consumer bidirectional between the express server and the consumer process?

kkodmani commented 1 year ago

You can simulate by

  1. Opening two terminals one for the usual server at 3000
  2. The other as node ./consumer (This terminal will consume anything that you feed into the the first terminal).

Is the producer/consumer bidirectional between the express server and the consumer process?

It could be, but not for this one. More info on it here

Producer keeps sending messages to a queue and does not know a consumer exists. A consumer will do nothing. When called, it will consume the messages and wait indefinitely until another message passes by. These can be configured in time as such timeouts and how long to wait before shutting down.

saladenicoise commented 1 year ago

At a cursory glance everything seems to be correct. I'll run it later today to make sure

kkodmani commented 1 year ago

Manually tested the code (aka ran the fromIp and fromAddress endpoints and the consumer works properly). Code looks good too. Check other comment for possible changes, otherwise approved.

Will wrap the code tomorrow morning 👍

saladenicoise commented 1 year ago

Manually tested it as well, returns all the weather data from the API, image