Add Custom Code Rules
What are Custom Code Rules?
Creating a Custom Code Rule
1
Allow only Alpine base images in Dockerfiles as base images2
3
# ✅ Code that follows the rule
FROM alpine:3.18
RUN apk add --no-cache nodejs# ❌ Code that violates the rule
FROM ubuntu:latest
RUN apt-get update && apt-get install nodejs4
5
Use Alpine base images in Docker containersNon-Alpine base images increase container size and attack surfaceReplace your base image with an Alpine Linux variant. For example, change 'FROM node:18' to 'FROM node:18-alpine'. You may need to adjust package installation commands from apt-get to apk.
Writing effective Custom Rules
Be specific and clear
Use proper error handlingAll API endpoints must wrap database calls in try-catch blocks and return
standardized error responses with status codesFocus on patterns, not style
Common Custom Rule examples
Security rules
Architecture rules
API standards
Testing requirements
Documentation standards
Last updated
Was this helpful?