Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit a warning when database URL is pasted directly into the schema #17640

Closed
millsp opened this issue Jan 30, 2023 · 8 comments
Closed

Emit a warning when database URL is pasted directly into the schema #17640

millsp opened this issue Jan 30, 2023 · 8 comments
Labels
domain/client Issue in the "Client" domain: Prisma Client, Prisma Studio etc. kind/improvement An improvement to existing feature and code. tech/typescript Issue for tech TypeScript. topic: cli topic: connection-url
Milestone

Comments

@millsp
Copy link
Member

millsp commented Jan 30, 2023

Problem

It should generally be considered a bad practice to paste a private database URL into the schema directly. If the user commits that schema by accident somewhere, or deploys it somewhere, they will be exposed to a security risk.

Suggested solution

I suggest that we emit a warning on prisma generate (maybe others too?) when we detect any URL that isn't pointing to localhost or 127.0.0.1 is pasted in the schema. This way, we can raise awareness around security and suggest users to either use .env or environment variables.

@millsp millsp added kind/improvement An improvement to existing feature and code. topic: connection-url topic: cli tech/typescript Issue for tech TypeScript. domain/client Issue in the "Client" domain: Prisma Client, Prisma Studio etc. size/s (<1 wk) labels Jan 30, 2023
@algora-pbc
Copy link

algora-pbc bot commented Sep 4, 2023

💎 $50 bounty created by prisma
🙋 If you start working on this, comment /attempt #17640 to notify everyone
👉 To claim this bounty, submit a pull request that includes the text /claim #17640 somewhere in its body
📝 Before proceeding, please make sure you can receive payouts in your country
💵 Payment arrives in your account 2-5 days after the bounty is rewarded
💯 You keep 100% of the bounty award
🙏 Thank you for contributing to prisma/prisma!

Attempt Started (GMT+0) Solution
🟢 @mnmt7 Sep 4, 2023, 8:40:43 AM WIP
🟢 @kunal00000 #20942

@mnmt7
Copy link

mnmt7 commented Sep 4, 2023

/attempt #17640

Options

@algora-pbc
Copy link

algora-pbc bot commented Sep 4, 2023

💡 @kunal00000 submitted a pull request that claims the bounty. You can visit your org dashboard to reward.

@petradonka
Copy link
Contributor

Hi @kunal00000 👋 Thank you for opening the PR 🙌

As we reviewed your PR, we have noticed that the warning we had intended to show up when you run prisma generate with a private database URL in your schema was already present. That's a miss on us, we had another issue tracking that work, and didn't close this one when we completed it.

We really appreciate the time and effort you've put into this though, and would still like to recognize that with rewarding you the bounty, as you were our first bounty-hunter! 🌟

@algora-pbc
Copy link

algora-pbc bot commented Sep 5, 2023

🎉🎈 @kunal00000 has been awarded $50! 🎈🎊

@janpio janpio added this to the 5.2.0 milestone Sep 5, 2023
@janpio
Copy link
Contributor

janpio commented Sep 5, 2023

This was implemented as part of #20731, which was shipped with release 5.2.0.

@kunal00000
Copy link

Hi @petradonka, thank you for your kindness 🙏. Would you like to get this done in other commands too (as I saw that it was not present in the prisma migrate dev command).

@janpio
Copy link
Contributor

janpio commented Sep 5, 2023

No, we intentionally only want a warning in prisma generate because that is the only command that actually persists a hard coded value in the generated Client. For migrate dev we feel that having a hard coded URL is a valid use case, and if you go into dangerous territory with prisma generate - you will get the warning.

We might tighten that later, but for now we are waiting for feedback on this level of deterrant of putting a plain connection string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain/client Issue in the "Client" domain: Prisma Client, Prisma Studio etc. kind/improvement An improvement to existing feature and code. tech/typescript Issue for tech TypeScript. topic: cli topic: connection-url
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants