Skip to content

Commit 6d30aca

Browse files
committed
docs: add lint-time security checks section to security best practices
Adds a short section on static analysis to the Production Best Practices: Security page. It complements the existing runtime protections and dependency scanning advice by covering lint-time detection of insecure patterns (hardcoded secrets, unsafe redirects, missing cookie flags, injection-prone string building). Resolves #2471 Signed-off-by: METHILA M <260591810+methila-2056@users.noreply.github.com>
1 parent b9d5106 commit 6d30aca

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/content/pages/en/advanced/best-practice-security.mdx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Security best practices for Express applications in production include:
3131
- [Prevent brute-force attacks against authorization](#prevent-brute-force-attacks-against-authorization)
3232
- [Ensure your dependencies are secure](#ensure-your-dependencies-are-secure)
3333
- [Avoid other known vulnerabilities](#avoid-other-known-vulnerabilities)
34+
- [Lint your code for security issues](#lint-your-code-for-security-issues)
3435
- [Additional considerations](#additional-considerations)
3536

3637
## Don't use deprecated or vulnerable versions of Express
@@ -304,6 +305,19 @@ Keep an eye out for [GitHub Advisory Database](https://github.com/advisories?que
304305

305306
Finally, Express apps&mdash;like any other web apps&mdash;can be vulnerable to a variety of web-based attacks. Familiarize yourself with known [web vulnerabilities](https://owasp.org/www-project-top-ten/) and take precautions to avoid them.
306307

308+
## Lint your code for security issues
309+
310+
Dependency scanning (as described above) checks the packages you install, but not the code you write. Static analysis tools catch insecure code patterns at lint time&mdash;before the code ships&mdash;such as:
311+
312+
- Hardcoded secrets and credentials in source code
313+
- Unsafe redirects (see [Prevent open redirects](#prevent-open-redirects))
314+
- Missing cookie security flags (see [Use cookies securely](#use-cookies-securely))
315+
- Injection-prone string building for SQL queries or shell commands
316+
317+
Most Express apps already run [ESLint](https://eslint.org/) for code quality, and several ESLint plugins add security-focused rules on top of it. Run these checks in CI alongside your tests so that new violations fail the build.
318+
319+
Static analysis complements, but does not replace, the runtime protections described on this page, such as Helmet and dependency scanning.
320+
307321
## Additional considerations
308322

309323
Here are some further recommendations from the excellent [Node.js Security Checklist](https://blog.risingstack.com/node-js-security-checklist/). Refer to that blog post for all the details on these recommendations:

0 commit comments

Comments
 (0)