TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Writing secure Go code

381 pointsby gus_leonel7 months ago

12 comments

rollulus7 months ago
As the article also mentions: instead of checking if your program has a dependency on something that contains vulnerabilities, govulncheck checks if vulnerable code is actually reached. I find that so awesome. (And I know, someone is going to point out that hipster language foo does this too and better — it’s not the norm).
评论 #42053143 未加载
评论 #42049095 未加载
jjcm7 months ago
Great tips in here - I was not aware of `go vet` nor `go test -race`.<p>FWIW, while go is not memory safe, I do find that it&#x27;s much easier to be safe in go than it is in other languages. Its verboseness lends to a very clear understanding of what&#x27;s happening in any given function. I absolutely hated this at the start, but now ~3 years into maintaining a go codebase, I find it quite nice both for debugging as well as editing old code. I know exactly what each function does, and what the structure of data is in any given context.<p>Another interesting side effect is that AI tools seem to work amazingly well with golang, given how context is often local to the function.
评论 #42048067 未加载
评论 #42048732 未加载
评论 #42046101 未加载
评论 #42049104 未加载
wepple7 months ago
Don’t forget about capslock: <a href="https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;capslock">https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;capslock</a><p>Assess your 3P modules for dangerous capabilities
评论 #42049606 未加载
tbiehn7 months ago
Semgrep is another great option to get value out of static analysis checks against both the language and a few common frameworks. It remains a popular choice for security folks writing static detection rules (and contributing them to the commons).<p>You can check the open rules here; <a href="https:&#x2F;&#x2F;github.com&#x2F;semgrep&#x2F;semgrep-rules&#x2F;tree&#x2F;develop&#x2F;go">https:&#x2F;&#x2F;github.com&#x2F;semgrep&#x2F;semgrep-rules&#x2F;tree&#x2F;develop&#x2F;go</a>
goodlinks7 months ago
Does go have a bad security reputation?<p>I get that anything can be insecure and its a constant battle as this article suggests, but i thought it was quite secure and stable generally (say on a par with .net or any other tool you may use to make a web app at least?)
评论 #42044926 未加载
评论 #42044749 未加载
评论 #42044663 未加载
评论 #42044586 未加载
评论 #42044762 未加载
评论 #42044641 未加载
评论 #42047268 未加载
gus_leonel7 months ago
TIL about `gosec`.
评论 #42051636 未加载
Xaki82717 months ago
Wow!
hasnain997 months ago
does it work
pram7 months ago
I&#x27;ve been maintaining a Go app for about 9 years now and I can just upgrade the Go version + mod for vulnerabilities (GitHub tells me about them automatically idk) and it works with no changes 99% of the time. I can&#x27;t overstate how this makes maintaining it very stress-free.<p>My JS apps on the other hand...
评论 #42045387 未加载
评论 #42045348 未加载
评论 #42046500 未加载
评论 #42044679 未加载
评论 #42045341 未加载
评论 #42049921 未加载
评论 #42045323 未加载
评论 #42046210 未加载
评论 #42045344 未加载
评论 #42047259 未加载
dakiol7 months ago
Go is nice, but the recent trend of using generics for many stuff is making harder and harder to keep Go code readable imho. See an example here <a href="https:&#x2F;&#x2F;eli.thegreenplace.net&#x2F;2024&#x2F;ranging-over-functions-in-go-123&#x2F;" rel="nofollow">https:&#x2F;&#x2F;eli.thegreenplace.net&#x2F;2024&#x2F;ranging-over-functions-in...</a><p>I&#x27;m not saying it&#x27;s hard to read, but it&#x27;s harder than previous Go code that used little or no generics at all.
评论 #42045690 未加载
评论 #42045641 未加载
评论 #42045696 未加载
评论 #42045779 未加载
评论 #42045704 未加载
评论 #42047254 未加载
K0nserv7 months ago
Somewhat related, I learned a surprising fact recently: Go is not actually memory safe. In particular because atomicity is only guaranteed for word size values, double word values(interface pointers, slices) can introduce memory unsafety in the presence of concurrency[0].<p>It&#x27;s one of those things that feels obvious when you see it.<p>0: <a href="https:&#x2F;&#x2F;blog.stalkr.net&#x2F;2015&#x2F;04&#x2F;golang-data-races-to-break-memory-safety.html" rel="nofollow">https:&#x2F;&#x2F;blog.stalkr.net&#x2F;2015&#x2F;04&#x2F;golang-data-races-to-break-m...</a>
评论 #42045906 未加载
评论 #42046045 未加载
评论 #42045903 未加载
评论 #42046650 未加载
评论 #42046985 未加载
评论 #42050136 未加载
评论 #42046342 未加载
评论 #42047263 未加载
评论 #42047258 未加载
tapirl7 months ago
Please note, currently, there are no tools to detect the new footguns created by the new semantics of 3-clause &quot;for;;&quot; loops: <a href="https:&#x2F;&#x2F;github.com&#x2F;golang&#x2F;go&#x2F;issues&#x2F;66156">https:&#x2F;&#x2F;github.com&#x2F;golang&#x2F;go&#x2F;issues&#x2F;66156</a><p>&gt; The second step is to keep the Go versions in our projects current. Even though we don’t use the latest and greatest language features, bumping the Go version gives us all security patches for discovered vulnerabilities.<p>It is not always a good strategy to use the latest toolchain version. There are often some fresh bugs in it. From the security perspective, it is better to use the previous version, which is also still being maintained.
评论 #42046965 未加载
评论 #42044982 未加载
评论 #42045998 未加载
评论 #42046401 未加载