A very basic REST service for JSON data - enough for prototyping and MVPs!
Features:
no need to set up a database, all data is managed automagically*
REST paradigm CRUD for multiple entities/namespaces
schema validation
search using jq like syntax
CORS enabled
easy to deploy as container
But for other strings built with sprintf, yes I am saying don't use %v unless for debugging, it's just one more avenue where you might be surprised by input, even if you're not building strings for sql. For example, someone might do this with user supplied data:
myoutput := fmt.Sprintf("user:%v",userID)
and if userID is a string like "foo" it'll end up in their string and they won't get what they expect. So better to just put another guardrail on there and insist that the param is an integer or whatever you expect by using %d which will only accept an int - this means you have to convert it to an integer first.
Many vulnerabilities are caused by data not being in the format people expect (not just sqli).
It should sanitize / quote arguments for you and protect against SQL injection. Note that this doesn't mean all data sanitization is performed, just the basic '; do my stuff here; -- type of things.
Using the db Exec / Query / Query row is the same amount of code and effort the fmt.Sprintf statements. Even in quick-and-dirty mock-ups, it's a good idea to not cut corners there.
There's nothing as permanent as a temporary solution. There's been countless SQL injection vulnerabilities exploited over the past decades with the "I'll fix it later" mindset.
Start with prepared statements by default, they are not more work than formatting strings.
> You're right of course, but I think the idea of this software is that the user (and, by extension, their input) are trusted.
No, you should enforce the most basic security practices even if the users are "trusted". Somebody might put that on the internet for a demo for client and get hacked in no time, because the code is opened to SQL injection. This isn't acceptable. There are minimum security standards every project should follow.
And since none of the minimum security standards are implemented in that project, I would not recommend using it until they are.
>>Now that it's been posted to HN you might see malicious actors.
This needs to be an HN fN Masterclass by @Dang....
We should have regular visibility into /how/ HN is used by malicious actors.... HN has enough pedigree to get some insight from some of the top security folks... and it would be REALLY good to know how HN is being harvested in this space.
Features: