r/node • • Aug 12 '20

MySQL manager - discord bot

451 Upvotes

98 comments sorted by

30

u/adamhighdef Aug 12 '20

Very cool, but.. why?

0

u/FoxBlood73 Aug 12 '20

Tbh because I am too lazy to connect to mysql servers from command line or from ssh. I made a discord bot that stores mysql servers and executes sql commands directly from discord.

30

u/ndm250 Aug 12 '20

MySQL workbench?

33

u/warchild4l Aug 12 '20

yeah no. Datagrip gang where you at

13

u/cheese_bread_boye Aug 12 '20

I use HeidiSQL and it's amazing. I don't do a lot of SQL work so heidi is just perfect for me.

4

u/warchild4l Aug 12 '20

Oh i use heidi as well. Just multiple tabs of datagrip is a must have.

10

u/mlk Aug 12 '20

Dbeaver Is free and awesome

4

u/vikkio Aug 12 '20

finally someone else who uses dbeaver, it's brilliant, only annoying thing, too many updates lol.

3

u/demonspeedin Aug 12 '20

Datagrip is amazing. The support to connect to a db over an ssh-tunnel is super convenient. (Yes I know you can do it by manually setting up the tunnel too but that takes time)

1

u/unknownguy2002 Aug 13 '20

Jetbrain products are amazing

-1

u/bitsandbytez Aug 12 '20

Broke from paying for the license

-7

u/FoxBlood73 Aug 12 '20

Didn't knew about that tool when I made it. I just wanted something fast to execute even from my phone.

18

u/CromulentEntity Aug 12 '20

You execute sql queries from your phone :o I could never be that confident

1

u/paulsmithkc Aug 30 '20

I think the OP hasn't accidentally dropped an entire table yet...

9

u/ajirnanashak Aug 12 '20

dbeaver is good too

1

u/mauvm Aug 12 '20

Have a look at SequelPro, HeidiSQL or TablePlus.

0

u/[deleted] Aug 12 '20

[deleted]

1

u/mauvm Aug 12 '20

They could use some screenshots on their site.

27

u/Gr1pp717 Aug 12 '20

Op, you're a victim of what you don't know here. And instead of providing some constructive feedback people are just downvoting you...

FWIW I think it's really cool that you made this. These sorts of tiny what-ifs are a great way to learn, and can often lead to even bigger things. Just know that it's a 1. a massive security risk and 2. not necessary as there's many UIs out there (which are native/not hooked into an online service)

Keep learning, and fuck the haters here.

-2

u/FoxBlood73 Aug 12 '20

Thank you for your support. I do know that is a big security risk, that's why I recommend on github to use this bot on a private server. Seems that this nodejs community is pretty salty sometimes lmao(does JavaScript programmers always salty? Xd) . Thank you again, I will keep learning JavaScript, (seems to be a powerful language) and post fun stuff I will have more.

16

u/[deleted] Aug 12 '20 edited Aug 12 '20

The only recommendation for this bot is to not use it for production databases. I personally wouldn’t even use it for non-prod because even if it doesn’t have prod data a hacker could see all your schemas to devise sql injections with. It’s a neat little tool but it seems to be a wrapper over a CLI that’s made public to anyone who can get access to that discord server.. you’re really relying on Discord to keep your DB secure which is a huge no no

1

u/PlaneCrashers Aug 13 '20

Well yeah, but I think it is fine for learning with dummy databases.

4

u/[deleted] Aug 13 '20

I mean honestly you could just use MySql workbench or something.

The github README should really mention that this is more of a POC - for fun type thing. But I think the author is genuinely serious about its practicality

1

u/PlaneCrashers Aug 13 '20

Yeah, like using it in mobile. I don't disagree, but I guess not a lot of people would have a use for it.

3

u/monox60 Aug 12 '20

I mean, it's not that they are really salty. It's pretty cool actually, but security risk is so high up there that it's a really big no no. A lot of companies are extremely strict and cautious of their DB, so this is like a slap on the face.

2

u/MoogleFoogle Aug 13 '20

so this is like a slap on the face

Someone throwing together a weird discord bot is a slap to the face of people who keep their datbases secure? Really? Maybe those people shouldn't take themselves so seriously and leave work at work.

1

u/monox60 Aug 13 '20

I agree. I think people look at it and think from a production standpoint instead of him just having fun.

1

u/paulsmithkc Aug 30 '20

Imagine being the DBA that has to tell a dev to shutdown a discord bot. DBAs already have enough security issues to work with.

1

u/paulsmithkc Aug 30 '20

People are taking issue with this because you are putting ALL of your company/clients data at serious risk. The database is the most important and vulnerable part of your application. We want that database locked up in fort Knox.

Opening a database for remote code execution from Discord, opens it up to a long list of security vulnerabilities.

Even putting the bot on a private server, with just yourself is not an acceptable risk for corporate/business data.

6

u/vivekc29 Aug 12 '20

It's nice. I believe you are learning Nodejs. Keep it up👍

8

u/FoxBlood73 Aug 12 '20

Yes, I do still learn nodejs, I made this bot for me, because I really wanted something like that and for practicing my skills.

3

u/RUGMJ7443 Aug 13 '20

I’m new to node but how did you split the discord commands like that I can only split them into arguments word by word how did you make it so you can input values

3

u/FoxBlood73 Aug 13 '20

I just used slice() function for removing the first characters from the message string. In the main entrance of the bot I just placed an if statement to check if the command starts with "sql" or not, it's really unnecessary to split the whole sql syntax into arguments. Here is my line:

const sql = message.content.slice(bot_config.prefix.length + 4).trim();

3

u/RUGMJ7443 Aug 13 '20

I mean in your arguments there were spaces how did they not get split into separate arguments?

2

u/FoxBlood73 Aug 13 '20

Take a look here at line 31: https://github.com/FoxBlood72/DisRemSQL/blob/master/index.js . If the command does not start with "sql" it just split the command

65

u/nwsm Aug 12 '20

Coming to production at a startup near you

48

u/nowtayneicangetinto Aug 12 '20

Future Stack Overflow post "does anyone know how to do an inner join on a crying laughing emoji?!"

1

u/[deleted] Aug 13 '20

Set collation to Apple bitmoji? Doesn't work with anything else though

86

u/gc_DataNerd Aug 12 '20

This is horrifying but good for you

29

u/CaptainTaelos Aug 12 '20

That's pretty cool! It doesn't seem very secure, but it is very neat indeed!

29

u/oskarious Aug 12 '20

This is so cursed, lmao. Someone should make a public bot and a dummy sql database and see how long it takes a discord server to crash the sql server

10

u/Fusseldieb Aug 12 '20

One DROPpy b0i and it's over

3

u/arrudagates Aug 13 '20

Don't even have to link the relevant xkcd

23

u/FullSlack Aug 12 '20

In today’s episode of “hilarious intern projects that were actually well made”

All jokes aside cool project, you could add security pretty easily if it isn’t already there.

7

u/BurningPenguin Aug 12 '20

Nice. Now lets create a database based on discord.

8

u/mkayxx Aug 12 '20

Should be pretty easy, right? You just pass the string to an sql query?

3

u/tedtosterone Aug 13 '20

Okay wow amazing. I need that.

3

u/bn326160 Aug 13 '20

Bad idea, but great execution! :)

7

u/simpleauthority Aug 12 '20

oh my god, absolutely not

2

u/haxd Aug 13 '20

DROP DATABASE tho

1

u/[deleted] Aug 13 '20

What’s the saying...? Never trust user input. Ever.

1

u/RUGMJ7443 Aug 13 '20

I’m new to node but how did you split the discord commands like that I can only split them into arguments word by word how did you make it so you can input values

1

u/[deleted] Aug 13 '20

Putting the database in a docker instance or whatever and use it as a sandbox environment. Could be useful for the ProgrammingHangout discord server for the SQL channel. Good job.

1

u/oze4 Aug 12 '20

This looks like a mess waiting to happen.

1

u/mlk Aug 12 '20

The waiting part isn't really needed

0

u/oze4 Aug 12 '20

What you mean? This is literally one massive, deliberate SQL injection.

0

u/mlk Aug 12 '20

I meant it's already a mess

1

u/oze4 Aug 13 '20

Lmao I was looking at the gif trying to find where there was something about waiting. Hahaha I'm an idiot.

1

u/santoso-sheep Aug 13 '20

Guys if youre going to flame OP then at least provide constructive feedback so they (and other people) can learn...

This reply should be at the top: https://www.reddit.com/r/node/comments/i8e52d/mysql_manager_discord_bot/g18rwms/?utm_source=share&utm_medium=ios_app&utm_name=iossmf

-2

u/FoxBlood73 Aug 12 '20

If anybody wants to use this bot just check my github page for more details: https://github.com/FoxBlood72/DisRemSQL

18

u/BagelRainbow Aug 12 '20

Your token is exposed in the commit history.

7

u/FoxBlood73 Aug 12 '20

Yeah I know, i changed it after I accidentally push it

10

u/DamnItDev Aug 12 '20

You'll want to amend your history. The token can be viewed by anyone by looking at the history of the commits.

https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History

https://www.atlassian.com/git/tutorials/rewriting-history

12

u/Chewsterchew Aug 12 '20 edited Aug 13 '20

You don't need to, once it's regenerated it's useless.

Discord also automatically revokes tokens pushed to GitHub

I'd be more concerned about the root password commited in the SQLite database file.

6

u/Fusseldieb Aug 12 '20

That escalated quickly

2

u/abc-123-456 Aug 12 '20

It's in there forever until you do surgery on git.

33

u/[deleted] Aug 12 '20

bruh .gitignore node_modules

10

u/FoxBlood73 Aug 12 '20

Didn't know that's a bad practice. First time in the city, sorry.

10

u/vivekc29 Aug 12 '20

So, we never push node modules (we git ignore this directory). We expect "npm install" to be executed whenever somebody clone and want to work on our repository.

12

u/[deleted] Aug 12 '20

It must have taken ages for you to push

4

u/spookysp00ks Aug 12 '20

Also don’t forget to git ignore env files with sensitive data on them.

1

u/unknownguy2002 Aug 13 '20

Search node.js git ignore and there's a github gist or file with a complete list of dirs and files that should be ignored, just add that to the root directory of your project. It's not a big issue, we all probably did this at one point or another

2

u/monxas Aug 12 '20

I use gitignore.io to mark what I’m using and it generates de file for me. They also have a vscode extension

1

u/cjthomp Aug 13 '20

Work on any fun side project you want to, but nobody should use this anywhere.

0

u/[deleted] Aug 12 '20

[deleted]

7

u/unknownguy2002 Aug 13 '20

Pay $5/month to get UNLIMTED security compromises. Add on another $1 per month for Cross-Site Scripting as a service

9

u/Rotinx Aug 12 '20

Lmao you got me rolling on the floor

-39

u/FoxBlood73 Aug 12 '20

Yeah, something like an injection service. But ofc you have to add mysql servers to database in order to execute sql commands.

39

u/warchild4l Aug 12 '20

someone did not get the joke

6

u/FoxBlood73 Aug 12 '20

I still do not get it :/

17

u/[deleted] Aug 12 '20

SQL injection is a type of security vulnerability. SaaS is "Software as a Service"

-16

u/FoxBlood73 Aug 12 '20

And why do people around here have to downvote me for that lmao. How I was supposed to know that does saas means? Xd

36

u/ZeroSevenTen Aug 12 '20

SaaS is a common phrase lol, and id suggest looking up some sql security 😉

5

u/[deleted] Aug 12 '20

You were downvoted coz u didn't get the joke, and you were the one who posted this as well. So you kinda broke the flow :P don't take it too seriously, it's just coz you didn't take the joke. Happens

-4

u/PlaneCrashers Aug 12 '20

It's reddit. Sometimes people do that. It's a shame, imo they should not, but they still do.

-35

u/DamnItDev Aug 12 '20

Your name has a blue box around it which singles you out as the OP. For some reason if you are the OP, reddit wants to downvote you. If you had posted the same reply from a different account, you wouldn't have had the same reaction. Probably would have been fully ignored, left at 1pt.

I don't understand this phenomenon but I have seen it across all subreddits.

26

u/Namiastka Aug 12 '20

Agree to disagree.. dev who is able to write bot like this should know what saas is and sql injection, and while i woudnt downvote for it , I see some reasoning Anyway, nice project to show on interview

3

u/PlaneCrashers Aug 12 '20

As much as I would expect someone working in the industry to know those things, this is reddit. No matter your level of proficiency, it's okay. OP made a cool thing and that's all what matters. The rest will come in time.

2

u/-IoI- Aug 13 '20

Downvoting to invalidate your hypothesis

1

u/DamnItDev Aug 13 '20

It doesn't invalidate anything. It is a clearly observable phenomenon. Downvoting me for pointing it out doesn't make it not exist. Humans in our culture hate being thought of as anything but free thinking individuals. Imply to them that cognitive dissonance is impairing rational behavior, and the brain immediately goes to five stages of grief, step 1: denial.

3

u/NetworkedOuija Aug 12 '20

You will want to Google SQL injection and then double check that your bot is as secure as it can be. From the looks of it. Your passing pure SQL to something that's running it, we HOPE your filtering it, but I don't know how you could from the position your bot is in. Your server could be vulnerable to injection.

4

u/NoInkling Aug 13 '20

I mean, the user writing SQL needs to be trusted or this would be useless in the first place. So (presumably) it's not like it's accepting untrusted input, unless we're talking about some sort of middleman injection.

1

u/paulsmithkc Aug 30 '20

It's a discord bot. It's absolutely accepting untrusted input. I highly doubt the OP has done any role checking, or that even if they did that the check is implemented securely.

1

u/NoInkling Aug 30 '20

Either way, the bot accepts full SQL statements, so the point about injection is basically moot. Either you trust all the users that are able to issue commands (looking at the repo, that does seem to mean the whole server in this case), or you essentially have no security at all anyway.

0

u/[deleted] Aug 13 '20

[deleted]

5

u/fun_egg Aug 13 '20

From op's GitHub repo

DisRemSQL is a Discord bot that can be used to manage MySQL servers. This project was made for managers of databases that wants to run SQL commands directly from Discord.

4

u/[deleted] Aug 12 '20

[removed] — view removed comment

3

u/[deleted] Aug 12 '20

I just configured this with my production database what is wrong with that.....? XD