@softspark/ai-toolkit 1.2.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +5 -29
- package/CHANGELOG.md +21 -0
- package/README.md +114 -17
- package/app/.claude-plugin/plugin.json +1 -1
- package/app/ARCHITECTURE.md +35 -19
- package/app/agents/ai-engineer.md +47 -5
- package/app/agents/fact-checker.md +1 -1
- package/app/agents/llm-ops-engineer.md +2 -2
- package/app/agents/{mcp-server-architect.md → mcp-specialist.md} +124 -18
- package/app/agents/mcp-testing-engineer.md +2 -2
- package/app/agents/nlp-engineer.md +1 -1
- package/app/agents/orchestrator.md +3 -4
- package/app/agents/project-planner.md +1 -1
- package/app/agents/technical-researcher.md +71 -21
- package/app/hooks/commit-quality.sh +53 -0
- package/app/hooks/governance-capture.sh +77 -0
- package/app/hooks/guard-config.sh +46 -0
- package/app/hooks/mcp-health.sh +53 -0
- package/app/hooks/pre-compact-save.sh +34 -0
- package/app/hooks/session-context.sh +60 -0
- package/app/hooks.json +60 -0
- package/app/mcp-templates/README.md +105 -0
- package/app/mcp-templates/brave-search.json +13 -0
- package/app/mcp-templates/cloudflare.json +14 -0
- package/app/mcp-templates/context7.json +10 -0
- package/app/mcp-templates/custom-template.json +13 -0
- package/app/mcp-templates/datadog.json +15 -0
- package/app/mcp-templates/docker.json +10 -0
- package/app/mcp-templates/fetch.json +10 -0
- package/app/mcp-templates/filesystem.json +10 -0
- package/app/mcp-templates/git.json +10 -0
- package/app/mcp-templates/github.json +13 -0
- package/app/mcp-templates/google-drive.json +15 -0
- package/app/mcp-templates/google-maps.json +13 -0
- package/app/mcp-templates/grafana.json +14 -0
- package/app/mcp-templates/linear.json +13 -0
- package/app/mcp-templates/memory.json +10 -0
- package/app/mcp-templates/notion.json +13 -0
- package/app/mcp-templates/postgres.json +10 -0
- package/app/mcp-templates/puppeteer.json +10 -0
- package/app/mcp-templates/redis.json +13 -0
- package/app/mcp-templates/sentry.json +14 -0
- package/app/mcp-templates/sequential-thinking.json +10 -0
- package/app/mcp-templates/slack.json +14 -0
- package/app/mcp-templates/sqlite.json +10 -0
- package/app/mcp-templates/supabase.json +14 -0
- package/app/mcp-templates/vercel.json +13 -0
- package/app/plugins/research-pack/README.md +1 -1
- package/app/plugins/research-pack/plugin.json +1 -1
- package/app/rules/claude-toolkit-rules.md +1 -1
- package/app/rules/common/coding-style.md +52 -0
- package/app/rules/common/git-workflow.md +45 -0
- package/app/rules/common/performance.md +49 -0
- package/app/rules/common/security.md +59 -0
- package/app/rules/common/testing.md +53 -0
- package/app/rules/cpp/coding-style.md +55 -0
- package/app/rules/cpp/frameworks.md +55 -0
- package/app/rules/cpp/patterns.md +57 -0
- package/app/rules/cpp/security.md +61 -0
- package/app/rules/cpp/testing.md +58 -0
- package/app/rules/csharp/coding-style.md +54 -0
- package/app/rules/csharp/frameworks.md +60 -0
- package/app/rules/csharp/patterns.md +61 -0
- package/app/rules/csharp/security.md +60 -0
- package/app/rules/csharp/testing.md +58 -0
- package/app/rules/dart/coding-style.md +61 -0
- package/app/rules/dart/frameworks.md +59 -0
- package/app/rules/dart/patterns.md +62 -0
- package/app/rules/dart/security.md +60 -0
- package/app/rules/dart/testing.md +60 -0
- package/app/rules/golang/coding-style.md +50 -0
- package/app/rules/golang/frameworks.md +56 -0
- package/app/rules/golang/patterns.md +52 -0
- package/app/rules/golang/security.md +61 -0
- package/app/rules/golang/testing.md +54 -0
- package/app/rules/java/coding-style.md +56 -0
- package/app/rules/java/frameworks.md +54 -0
- package/app/rules/java/patterns.md +59 -0
- package/app/rules/java/security.md +60 -0
- package/app/rules/java/testing.md +55 -0
- package/app/rules/kotlin/coding-style.md +56 -0
- package/app/rules/kotlin/frameworks.md +54 -0
- package/app/rules/kotlin/patterns.md +54 -0
- package/app/rules/kotlin/security.md +62 -0
- package/app/rules/kotlin/testing.md +56 -0
- package/app/rules/php/coding-style.md +53 -0
- package/app/rules/php/frameworks.md +57 -0
- package/app/rules/php/patterns.md +63 -0
- package/app/rules/php/security.md +61 -0
- package/app/rules/php/testing.md +60 -0
- package/app/rules/python/coding-style.md +52 -0
- package/app/rules/python/frameworks.md +53 -0
- package/app/rules/python/patterns.md +53 -0
- package/app/rules/python/security.md +58 -0
- package/app/rules/python/testing.md +52 -0
- package/app/rules/ruby/coding-style.md +56 -0
- package/app/rules/ruby/frameworks.md +56 -0
- package/app/rules/ruby/patterns.md +61 -0
- package/app/rules/ruby/security.md +61 -0
- package/app/rules/ruby/testing.md +63 -0
- package/app/rules/rust/coding-style.md +52 -0
- package/app/rules/rust/frameworks.md +59 -0
- package/app/rules/rust/patterns.md +58 -0
- package/app/rules/rust/security.md +64 -0
- package/app/rules/rust/testing.md +54 -0
- package/app/rules/swift/coding-style.md +55 -0
- package/app/rules/swift/frameworks.md +63 -0
- package/app/rules/swift/patterns.md +63 -0
- package/app/rules/swift/security.md +63 -0
- package/app/rules/swift/testing.md +60 -0
- package/app/rules/typescript/coding-style.md +51 -0
- package/app/rules/typescript/frameworks.md +51 -0
- package/app/rules/typescript/patterns.md +51 -0
- package/app/rules/typescript/security.md +55 -0
- package/app/rules/typescript/testing.md +52 -0
- package/app/skills/app-builder/SKILL.md +1 -1
- package/app/skills/brand-voice/SKILL.md +92 -0
- package/app/skills/council/SKILL.md +133 -0
- package/app/skills/introspect/SKILL.md +125 -0
- package/bin/ai-toolkit.js +103 -2
- package/kb/reference/agents-catalog.md +10 -13
- package/kb/reference/architecture-overview.md +29 -6
- package/kb/reference/commands-catalog.md +4 -4
- package/kb/reference/competitive-features-implementation.md +677 -0
- package/kb/reference/extension-api.md +175 -0
- package/kb/reference/hooks-catalog.md +90 -14
- package/kb/reference/language-rules.md +167 -0
- package/kb/reference/manifest-install.md +165 -0
- package/kb/reference/mcp-templates.md +110 -0
- package/kb/reference/skills-catalog.md +9 -6
- package/llms-full.txt +1511 -59
- package/llms.txt +8 -3
- package/package.json +2 -2
- package/scripts/inject_hook_cli.py +330 -0
- package/scripts/install.py +241 -7
- package/scripts/install_steps/ai_tools.py +63 -1
- package/scripts/install_steps/detect_language.py +50 -0
- package/scripts/install_steps/install_state.py +117 -0
- package/scripts/mcp_manager.py +206 -0
- package/app/agents/mcp-expert.md +0 -228
- package/app/agents/rag-engineer.md +0 -201
- package/app/agents/research-synthesizer.md +0 -138
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
language: golang
|
|
3
|
+
category: security
|
|
4
|
+
version: "1.0.0"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Go Security
|
|
8
|
+
|
|
9
|
+
## Input Validation
|
|
10
|
+
- Validate all input at API boundaries. Use struct tags or manual validation.
|
|
11
|
+
- Use `validator` package for struct validation: `validate:"required,email"`.
|
|
12
|
+
- Parse and validate numeric IDs: `strconv.Atoi()` with error checking.
|
|
13
|
+
- Limit request body size: `http.MaxBytesReader(w, r.Body, maxBytes)`.
|
|
14
|
+
|
|
15
|
+
## SQL Injection
|
|
16
|
+
- Always use parameterized queries: `db.Query("SELECT * FROM users WHERE id = $1", id)`.
|
|
17
|
+
- Never concatenate user input into SQL strings.
|
|
18
|
+
- Use `sqlx.In()` for safe dynamic IN clauses.
|
|
19
|
+
- Use ORM query builders (GORM, Ent) for dynamic query construction.
|
|
20
|
+
|
|
21
|
+
## Command Injection
|
|
22
|
+
- Use `exec.Command("binary", args...)` with separate arguments, not shell strings.
|
|
23
|
+
- Never use `exec.Command("sh", "-c", userInput)`.
|
|
24
|
+
- Validate and sanitize file paths against traversal attacks.
|
|
25
|
+
- Use `filepath.Clean()` and verify paths are within allowed directories.
|
|
26
|
+
|
|
27
|
+
## Cryptography
|
|
28
|
+
- Use `crypto/rand` for random values, never `math/rand` for security.
|
|
29
|
+
- Use `bcrypt` or `argon2` for password hashing: `golang.org/x/crypto/bcrypt`.
|
|
30
|
+
- Use `crypto/subtle.ConstantTimeCompare()` for timing-safe comparisons.
|
|
31
|
+
- Use `crypto/tls` with `tls.Config{MinVersion: tls.VersionTLS12}`.
|
|
32
|
+
|
|
33
|
+
## Secrets
|
|
34
|
+
- Load secrets from environment variables: `os.Getenv("SECRET_KEY")`.
|
|
35
|
+
- Never hardcode secrets, tokens, or API keys in source code.
|
|
36
|
+
- Use `go-envconfig` or similar for validated env var loading.
|
|
37
|
+
- Use Go build tags or ldflags for build-time configuration.
|
|
38
|
+
|
|
39
|
+
## HTTP Security
|
|
40
|
+
- Set `ReadTimeout`, `WriteTimeout`, `IdleTimeout` on `http.Server`.
|
|
41
|
+
- Use `helmet`-equivalent headers: HSTS, X-Content-Type-Options, X-Frame-Options.
|
|
42
|
+
- Implement rate limiting with `golang.org/x/time/rate` or middleware.
|
|
43
|
+
- Use `net/http` with TLS. Never serve production HTTP without encryption.
|
|
44
|
+
|
|
45
|
+
## Concurrency Safety
|
|
46
|
+
- Use `sync.Mutex` or `sync.RWMutex` for shared mutable state.
|
|
47
|
+
- Run `go test -race` in CI to detect data races.
|
|
48
|
+
- Avoid shared state where possible. Prefer channels for communication.
|
|
49
|
+
- Use `atomic` package for simple counters and flags.
|
|
50
|
+
|
|
51
|
+
## Dependencies
|
|
52
|
+
- Run `govulncheck ./...` in CI to check for known vulnerabilities.
|
|
53
|
+
- Use `go mod tidy` to remove unused dependencies.
|
|
54
|
+
- Pin dependencies via `go.sum`. Review dependency changes in PRs.
|
|
55
|
+
- Audit transitive dependencies. Use `go mod graph` to inspect the tree.
|
|
56
|
+
|
|
57
|
+
## Error Information Disclosure
|
|
58
|
+
- Never expose internal error messages to clients.
|
|
59
|
+
- Log detailed errors server-side, return generic messages to clients.
|
|
60
|
+
- Use error codes for machine-readable error classification.
|
|
61
|
+
- Do not include stack traces in production API responses.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
language: golang
|
|
3
|
+
category: testing
|
|
4
|
+
version: "1.0.0"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Go Testing
|
|
8
|
+
|
|
9
|
+
## Framework
|
|
10
|
+
- Use the standard `testing` package. No external test frameworks required.
|
|
11
|
+
- Use `testify/assert` and `testify/require` for readable assertions.
|
|
12
|
+
- Use `testify/mock` or `mockgen` for generating mocks.
|
|
13
|
+
- Use `go test -race` in CI to detect data races.
|
|
14
|
+
|
|
15
|
+
## File Naming
|
|
16
|
+
- Test files: `*_test.go` in the same package.
|
|
17
|
+
- Black-box tests: use `package foo_test` to test only exported API.
|
|
18
|
+
- White-box tests: use `package foo` to test internals.
|
|
19
|
+
- Test helpers: `testutil_test.go` or `testdata/` directory.
|
|
20
|
+
|
|
21
|
+
## Table-Driven Tests
|
|
22
|
+
- Use table-driven tests for functions with multiple input/output cases.
|
|
23
|
+
- Name each case: `{name: "empty input returns error", input: "", wantErr: true}`.
|
|
24
|
+
- Use `t.Run(tc.name, func(t *testing.T) { ... })` for subtests.
|
|
25
|
+
- Use `t.Parallel()` in subtests when tests are independent.
|
|
26
|
+
|
|
27
|
+
## Test Helpers
|
|
28
|
+
- Use `t.Helper()` in helper functions for correct line reporting.
|
|
29
|
+
- Use `t.Cleanup()` for teardown instead of defer in test functions.
|
|
30
|
+
- Use `testing.TB` interface to share helpers between tests and benchmarks.
|
|
31
|
+
- Use `testdata/` directory for test fixtures (excluded from build).
|
|
32
|
+
|
|
33
|
+
## Mocking
|
|
34
|
+
- Define interfaces at the consumer, not the provider.
|
|
35
|
+
- Use `mockgen` to auto-generate mocks from interfaces.
|
|
36
|
+
- Use `httptest.NewServer()` for HTTP integration tests.
|
|
37
|
+
- Use `httptest.NewRecorder()` for handler unit tests.
|
|
38
|
+
|
|
39
|
+
## Integration Tests
|
|
40
|
+
- Use build tags: `//go:build integration` to separate from unit tests.
|
|
41
|
+
- Use `testcontainers-go` for database/service containers in tests.
|
|
42
|
+
- Use `t.Setenv()` (Go 1.17+) for environment variable testing.
|
|
43
|
+
|
|
44
|
+
## Benchmarks
|
|
45
|
+
- Use `func BenchmarkXxx(b *testing.B)` with `b.N` loop.
|
|
46
|
+
- Use `b.ResetTimer()` after expensive setup.
|
|
47
|
+
- Use `b.ReportAllocs()` to track allocations.
|
|
48
|
+
- Run: `go test -bench=. -benchmem`.
|
|
49
|
+
|
|
50
|
+
## Coverage
|
|
51
|
+
- Run: `go test -coverprofile=coverage.out ./...`.
|
|
52
|
+
- View: `go tool cover -html=coverage.out`.
|
|
53
|
+
- Set minimum coverage threshold in CI.
|
|
54
|
+
- Focus coverage on business logic, not generated code.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
language: java
|
|
3
|
+
category: coding-style
|
|
4
|
+
version: "1.0.0"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Java Coding Style
|
|
8
|
+
|
|
9
|
+
## Naming
|
|
10
|
+
- PascalCase: classes, interfaces, enums, records, annotations.
|
|
11
|
+
- camelCase: methods, variables, parameters.
|
|
12
|
+
- UPPER_SNAKE: constants (`static final`).
|
|
13
|
+
- Package names: lowercase, dot-separated, reverse domain (`com.company.project`).
|
|
14
|
+
- No Hungarian notation. No `I` prefix on interfaces.
|
|
15
|
+
|
|
16
|
+
## Modern Java (17+)
|
|
17
|
+
- Use `record` for immutable data carriers. No need for Lombok in most cases.
|
|
18
|
+
- Use `sealed` classes/interfaces for restricted hierarchies.
|
|
19
|
+
- Use pattern matching: `if (obj instanceof String s)` instead of cast.
|
|
20
|
+
- Use `switch` expressions with arrow syntax and exhaustiveness.
|
|
21
|
+
- Use text blocks (`"""`) for multiline strings (SQL, JSON, HTML).
|
|
22
|
+
|
|
23
|
+
## Types
|
|
24
|
+
- Use `var` for local variables when the type is obvious from the right-hand side.
|
|
25
|
+
- Use `Optional<T>` for return types that may be absent. Never for fields or params.
|
|
26
|
+
- Prefer `List.of()`, `Map.of()`, `Set.of()` for immutable collections.
|
|
27
|
+
- Use `Stream` for collection transformations. Avoid streams for simple iterations.
|
|
28
|
+
|
|
29
|
+
## Classes
|
|
30
|
+
- Prefer composition over inheritance. Use interfaces for abstraction.
|
|
31
|
+
- Keep classes focused: single responsibility.
|
|
32
|
+
- Use `final` on classes not designed for extension.
|
|
33
|
+
- Use `private` constructors + static factory methods for controlled instantiation.
|
|
34
|
+
- Records over POJOs for value types. Lombok only if records are insufficient.
|
|
35
|
+
|
|
36
|
+
## Methods
|
|
37
|
+
- Max 20-30 lines per method. Extract when longer.
|
|
38
|
+
- Use `@Override` on every overridden method.
|
|
39
|
+
- Return empty collections over `null`. Use `Collections.emptyList()` or `List.of()`.
|
|
40
|
+
- Avoid checked exceptions for programming errors. Use runtime exceptions.
|
|
41
|
+
|
|
42
|
+
## Formatting
|
|
43
|
+
- Use project formatter (Google Java Format or IDE-configured).
|
|
44
|
+
- Use `@SuppressWarnings` sparingly and with specific warning names.
|
|
45
|
+
- Use `final` for parameters and local variables where practical.
|
|
46
|
+
|
|
47
|
+
## Nullability
|
|
48
|
+
- Annotate with `@Nullable` / `@NonNull` from JSpecify or JetBrains.
|
|
49
|
+
- Use `Objects.requireNonNull()` at public API boundaries.
|
|
50
|
+
- Never return `null` from collections or arrays. Return empty.
|
|
51
|
+
- Use `Optional` for genuinely optional return values.
|
|
52
|
+
|
|
53
|
+
## Documentation
|
|
54
|
+
- Javadoc on all public classes and methods.
|
|
55
|
+
- Use `@param`, `@return`, `@throws` tags for public API methods.
|
|
56
|
+
- Skip Javadoc for obvious getters, `toString()`, and `equals()`.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
language: java
|
|
3
|
+
category: frameworks
|
|
4
|
+
version: "1.0.0"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Java Frameworks
|
|
8
|
+
|
|
9
|
+
## Spring Boot
|
|
10
|
+
- Use Spring Boot 3+ with Java 17+ minimum.
|
|
11
|
+
- Use `@RestController` for REST APIs. Return `ResponseEntity` for status control.
|
|
12
|
+
- Use `@Valid` + Jakarta Bean Validation for request validation.
|
|
13
|
+
- Use profiles (`@Profile`) for environment-specific configuration.
|
|
14
|
+
- Use `application.yml` over `application.properties` for readability.
|
|
15
|
+
- Externalize config: env vars > config files > hardcoded defaults.
|
|
16
|
+
|
|
17
|
+
## Spring Data JPA
|
|
18
|
+
- Use repository interfaces extending `JpaRepository`.
|
|
19
|
+
- Use `@Query` with JPQL for custom queries. Use native queries only when needed.
|
|
20
|
+
- Use `@EntityGraph` to prevent N+1 queries in associations.
|
|
21
|
+
- Use `Specification` for dynamic query building.
|
|
22
|
+
- Always use `@Transactional` at the service layer, not repository.
|
|
23
|
+
|
|
24
|
+
## Spring Security
|
|
25
|
+
- Use `SecurityFilterChain` bean configuration (not `WebSecurityConfigurerAdapter`).
|
|
26
|
+
- Use `@PreAuthorize` / `@Secured` for method-level authorization.
|
|
27
|
+
- Use BCrypt for password encoding: `new BCryptPasswordEncoder()`.
|
|
28
|
+
- Configure CORS, CSRF, and session management explicitly.
|
|
29
|
+
- Use OAuth2 Resource Server for JWT validation in APIs.
|
|
30
|
+
|
|
31
|
+
## Hibernate / JPA
|
|
32
|
+
- Use `FetchType.LAZY` by default on all associations.
|
|
33
|
+
- Use `@BatchSize` or `@Fetch(FetchMode.SUBSELECT)` to avoid N+1.
|
|
34
|
+
- Use `@Version` for optimistic locking on entities.
|
|
35
|
+
- Use DTOs (records) for read queries. Do not expose entities in APIs.
|
|
36
|
+
- Use Flyway or Liquibase for schema migrations.
|
|
37
|
+
|
|
38
|
+
## Quarkus / Micronaut
|
|
39
|
+
- Use for microservices and serverless where startup time matters.
|
|
40
|
+
- Use compile-time DI (Micronaut) or build-time optimization (Quarkus).
|
|
41
|
+
- Use reactive patterns with Mutiny (Quarkus) or Reactor (Micronaut).
|
|
42
|
+
- Use native image builds with GraalVM for production deployments.
|
|
43
|
+
|
|
44
|
+
## Build Tools
|
|
45
|
+
- Use Gradle (Kotlin DSL) for new projects. Maven for enterprise legacy.
|
|
46
|
+
- Use dependency management to unify versions across modules.
|
|
47
|
+
- Use Bill of Materials (BOM) imports for consistent Spring versions.
|
|
48
|
+
- Use Spotless or Checkstyle for enforced code formatting.
|
|
49
|
+
|
|
50
|
+
## Logging
|
|
51
|
+
- Use SLF4J facade with Logback or Log4j2 backend.
|
|
52
|
+
- Use structured logging with MDC for correlation IDs.
|
|
53
|
+
- Use parameterized logging: `log.info("User {} created", userId)`.
|
|
54
|
+
- Never log sensitive data (passwords, tokens, PII).
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
language: java
|
|
3
|
+
category: patterns
|
|
4
|
+
version: "1.0.0"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Java Patterns
|
|
8
|
+
|
|
9
|
+
## Error Handling
|
|
10
|
+
- Use unchecked exceptions for programming errors (`IllegalArgumentException`).
|
|
11
|
+
- Use checked exceptions only for recoverable conditions the caller must handle.
|
|
12
|
+
- Create domain exception hierarchy: `AppException` -> `NotFoundException`, etc.
|
|
13
|
+
- Never catch `Exception` or `Throwable` broadly. Catch specific types.
|
|
14
|
+
- Use `try-with-resources` for all `AutoCloseable` resources.
|
|
15
|
+
|
|
16
|
+
## Immutability
|
|
17
|
+
- Use `record` for immutable value objects (Java 16+).
|
|
18
|
+
- Use `List.copyOf()`, `Map.copyOf()` to create unmodifiable copies.
|
|
19
|
+
- Make fields `private final`. No setters unless mutation is required.
|
|
20
|
+
- Return defensive copies of mutable collections from getters.
|
|
21
|
+
- Use builder pattern for constructing immutable objects with many fields.
|
|
22
|
+
|
|
23
|
+
## Optional
|
|
24
|
+
- Use `Optional<T>` as return type for methods that may not return a value.
|
|
25
|
+
- Chain: `optional.map(...).orElseThrow(...)`. Avoid `isPresent()` + `get()`.
|
|
26
|
+
- Never use `Optional` for fields, method parameters, or collection elements.
|
|
27
|
+
- Use `Optional.empty()` over `null`. Use `Optional.ofNullable()` at boundaries.
|
|
28
|
+
|
|
29
|
+
## Streams
|
|
30
|
+
- Use streams for transformations: `filter`, `map`, `collect`.
|
|
31
|
+
- Avoid side effects in stream operations. Keep them pure.
|
|
32
|
+
- Use `Collectors.toUnmodifiableList()` for immutable results.
|
|
33
|
+
- Prefer `for` loop for simple iterations that do not transform data.
|
|
34
|
+
- Use `Stream.of()` or `IntStream.range()` for generating sequences.
|
|
35
|
+
|
|
36
|
+
## Dependency Injection
|
|
37
|
+
- Use constructor injection exclusively. No field or setter injection.
|
|
38
|
+
- Accept interfaces in constructors, not implementations.
|
|
39
|
+
- Use `@Component`, `@Service`, `@Repository` for Spring-managed beans.
|
|
40
|
+
- Keep the number of constructor dependencies under 5. Split if more.
|
|
41
|
+
|
|
42
|
+
## Concurrency
|
|
43
|
+
- Use `ExecutorService` and `CompletableFuture` for async operations.
|
|
44
|
+
- Use `virtual threads` (Java 21+) for I/O-bound concurrent work.
|
|
45
|
+
- Use `ConcurrentHashMap`, `AtomicInteger` for thread-safe operations.
|
|
46
|
+
- Avoid `synchronized` blocks when possible -- use higher-level concurrency.
|
|
47
|
+
- Use `ReentrantReadWriteLock` for read-heavy shared state.
|
|
48
|
+
|
|
49
|
+
## Design Patterns
|
|
50
|
+
- Use Strategy pattern (via interfaces) over switch/if-else chains.
|
|
51
|
+
- Use Factory methods for flexible object creation.
|
|
52
|
+
- Use Decorator pattern for composable behavior augmentation.
|
|
53
|
+
- Avoid Singleton pattern -- use DI container for lifecycle management.
|
|
54
|
+
|
|
55
|
+
## Anti-Patterns
|
|
56
|
+
- Returning `null` from methods -- use `Optional` or empty collections.
|
|
57
|
+
- Mutable DTOs with getters/setters -- use records.
|
|
58
|
+
- God classes with 20+ dependencies -- split by responsibility.
|
|
59
|
+
- String typing for domain values -- use types, enums, or value objects.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
language: java
|
|
3
|
+
category: security
|
|
4
|
+
version: "1.0.0"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Java Security
|
|
8
|
+
|
|
9
|
+
## Input Validation
|
|
10
|
+
- Validate all input with Jakarta Bean Validation (`@NotNull`, `@Size`, `@Email`).
|
|
11
|
+
- Use `@Valid` on controller parameters to trigger validation automatically.
|
|
12
|
+
- Create custom validators for domain-specific rules.
|
|
13
|
+
- Never trust client-provided IDs. Verify resource ownership server-side.
|
|
14
|
+
|
|
15
|
+
## SQL Injection
|
|
16
|
+
- Use JPA/Hibernate parameterized queries. Never concatenate input into JPQL/SQL.
|
|
17
|
+
- Use `CriteriaBuilder` or Specifications for dynamic queries.
|
|
18
|
+
- For native queries, use named parameters: `@Query(value = "... WHERE id = :id", nativeQuery = true)`.
|
|
19
|
+
- Use `PreparedStatement` if using JDBC directly. Never `Statement` with concatenation.
|
|
20
|
+
|
|
21
|
+
## Authentication
|
|
22
|
+
- Use Spring Security with BCrypt (`BCryptPasswordEncoder`) for password hashing.
|
|
23
|
+
- Use JWT with short expiration (15 min) + refresh tokens for APIs.
|
|
24
|
+
- Implement account lockout after N failed attempts.
|
|
25
|
+
- Use `@AuthenticationPrincipal` to access the current user in controllers.
|
|
26
|
+
|
|
27
|
+
## Authorization
|
|
28
|
+
- Use `@PreAuthorize("hasRole('ADMIN')")` for role-based access control.
|
|
29
|
+
- Use method security for fine-grained authorization.
|
|
30
|
+
- Check resource ownership in service layer, not just role membership.
|
|
31
|
+
- Default deny: require explicit authorization for every endpoint.
|
|
32
|
+
|
|
33
|
+
## XSS and CSRF
|
|
34
|
+
- Spring auto-escapes Thymeleaf output. Do not use `th:utext` with user data.
|
|
35
|
+
- Enable CSRF protection for session-based auth. Disable only for stateless JWT APIs.
|
|
36
|
+
- Set `Content-Type` headers explicitly on responses.
|
|
37
|
+
- Use CSP headers to restrict script sources.
|
|
38
|
+
|
|
39
|
+
## Serialization
|
|
40
|
+
- Do not deserialize untrusted data with `ObjectInputStream` (RCE risk).
|
|
41
|
+
- Use Jackson with `@JsonIgnoreProperties(ignoreUnknown = true)`.
|
|
42
|
+
- Disable default typing in Jackson: never use `enableDefaultTyping()`.
|
|
43
|
+
- Validate deserialized objects with Bean Validation after parsing.
|
|
44
|
+
|
|
45
|
+
## Dependencies
|
|
46
|
+
- Run OWASP Dependency-Check in CI: `mvn verify -P owasp-check`.
|
|
47
|
+
- Update Spring Boot regularly -- security patches are frequent.
|
|
48
|
+
- Use `dependencyManagement` to control transitive dependency versions.
|
|
49
|
+
- Audit `mvn dependency:tree` for unexpected transitive dependencies.
|
|
50
|
+
|
|
51
|
+
## Secrets
|
|
52
|
+
- Use Spring Cloud Config or Vault for secrets management.
|
|
53
|
+
- Use `@Value("${secret}")` with env var placeholders, not hardcoded values.
|
|
54
|
+
- Never log request headers containing `Authorization` or session tokens.
|
|
55
|
+
- Use separate config profiles for dev/staging/prod with different secrets.
|
|
56
|
+
|
|
57
|
+
## Logging Security
|
|
58
|
+
- Use parameterized logging to prevent log injection.
|
|
59
|
+
- Sanitize user input before logging: remove newlines and control characters.
|
|
60
|
+
- Never log stack traces to API responses. Return generic error messages.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
language: java
|
|
3
|
+
category: testing
|
|
4
|
+
version: "1.0.0"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Java Testing
|
|
8
|
+
|
|
9
|
+
## Framework
|
|
10
|
+
- Use JUnit 5 (Jupiter) for all new tests. No JUnit 4.
|
|
11
|
+
- Use AssertJ for fluent, readable assertions.
|
|
12
|
+
- Use Mockito for mocking dependencies.
|
|
13
|
+
- Use Testcontainers for integration tests with databases/services.
|
|
14
|
+
|
|
15
|
+
## File Naming
|
|
16
|
+
- Test classes: `FooTest.java` in `src/test/java/` mirroring source package.
|
|
17
|
+
- Integration tests: `FooIT.java` or use `@Tag("integration")`.
|
|
18
|
+
- Test utilities: `src/test/java/.../support/` or `TestUtils.java`.
|
|
19
|
+
|
|
20
|
+
## Structure
|
|
21
|
+
- Use `@Nested` classes to group related tests within a test class.
|
|
22
|
+
- Use `@DisplayName` for human-readable test descriptions.
|
|
23
|
+
- Use `@BeforeEach` for setup, `@AfterEach` for cleanup.
|
|
24
|
+
- Use `@ParameterizedTest` with `@ValueSource`, `@CsvSource`, `@MethodSource`.
|
|
25
|
+
|
|
26
|
+
## Assertions (AssertJ)
|
|
27
|
+
- Use `assertThat(actual).isEqualTo(expected)` over JUnit assertions.
|
|
28
|
+
- Use `assertThatThrownBy(() -> ...).isInstanceOf(FooException.class)`.
|
|
29
|
+
- Use `assertThat(list).hasSize(3).extracting("name").contains("Ada")`.
|
|
30
|
+
- Chain assertions for readable, self-documenting tests.
|
|
31
|
+
|
|
32
|
+
## Mocking (Mockito)
|
|
33
|
+
- Use `@Mock` + `@ExtendWith(MockitoExtension.class)` for injection.
|
|
34
|
+
- Use `when().thenReturn()` for stubbing. `verify()` for interaction checking.
|
|
35
|
+
- Use `@InjectMocks` to auto-inject mocks into the class under test.
|
|
36
|
+
- Prefer constructor injection in production code for testability.
|
|
37
|
+
- Use `ArgumentCaptor` to inspect complex arguments.
|
|
38
|
+
|
|
39
|
+
## Integration Testing
|
|
40
|
+
- Use Testcontainers for PostgreSQL, Redis, Kafka, etc.
|
|
41
|
+
- Use `@SpringBootTest` sparingly -- it starts the full context. Prefer slices.
|
|
42
|
+
- Use `@WebMvcTest` for controller tests, `@DataJpaTest` for repository tests.
|
|
43
|
+
- Use `@TestConfiguration` for test-specific bean overrides.
|
|
44
|
+
|
|
45
|
+
## Test Data
|
|
46
|
+
- Use test builders or factory methods for creating test objects.
|
|
47
|
+
- Use `@Sql` annotation to load test data from SQL files.
|
|
48
|
+
- Keep test data minimal. Only set fields relevant to the behavior under test.
|
|
49
|
+
- Use random UUIDs for IDs in tests to avoid collision.
|
|
50
|
+
|
|
51
|
+
## Performance
|
|
52
|
+
- Run tests in parallel: configure `junit.jupiter.execution.parallel.enabled=true`.
|
|
53
|
+
- Use `@SpringBootTest` only when integration context is needed.
|
|
54
|
+
- Mock external dependencies in unit tests for speed.
|
|
55
|
+
- Keep the full test suite under 5 minutes.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
language: kotlin
|
|
3
|
+
category: coding-style
|
|
4
|
+
version: "1.0.0"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Kotlin Coding Style
|
|
8
|
+
|
|
9
|
+
## Naming
|
|
10
|
+
- PascalCase: classes, interfaces, objects, type aliases, enum entries.
|
|
11
|
+
- camelCase: functions, properties, local variables, parameters.
|
|
12
|
+
- UPPER_SNAKE: compile-time constants (`const val`), top-level `val` constants.
|
|
13
|
+
- Backing properties: prefix with `_` (`private val _items`, `val items: List<T>`).
|
|
14
|
+
- Package names: lowercase, no underscores (`com.company.project.feature`).
|
|
15
|
+
|
|
16
|
+
## Null Safety
|
|
17
|
+
- Use nullable types only when nullability is semantically meaningful.
|
|
18
|
+
- Prefer `?.let { }`, `?:` (Elvis), and safe calls over `!!`.
|
|
19
|
+
- Never use `!!` except in tests or when null is truly impossible.
|
|
20
|
+
- Use `requireNotNull()` and `require()` for preconditions at public API boundaries.
|
|
21
|
+
- Use `checkNotNull()` and `check()` for state assertions.
|
|
22
|
+
|
|
23
|
+
## Data Classes
|
|
24
|
+
- Use `data class` for DTOs, value objects, and state containers.
|
|
25
|
+
- Use `copy()` for immutable updates. Avoid mutable `var` in data classes.
|
|
26
|
+
- Use `sealed class` / `sealed interface` for restricted hierarchies.
|
|
27
|
+
- Use `value class` (inline class) for type-safe wrappers with zero overhead.
|
|
28
|
+
- Use `object` for singletons and namespace-like utility groupings.
|
|
29
|
+
|
|
30
|
+
## Functions
|
|
31
|
+
- Use expression body (`= expr`) for single-expression functions.
|
|
32
|
+
- Use named arguments for functions with >2 parameters of the same type.
|
|
33
|
+
- Use default parameter values instead of overloaded functions.
|
|
34
|
+
- Use extension functions to add behavior without inheritance.
|
|
35
|
+
- Use `suspend` functions for async operations, not callbacks.
|
|
36
|
+
|
|
37
|
+
## Collections
|
|
38
|
+
- Prefer `listOf`, `mapOf`, `setOf` (immutable) over `mutableListOf`.
|
|
39
|
+
- Use collection operators: `map`, `filter`, `groupBy`, `associate`.
|
|
40
|
+
- Use `sequence {}` for lazy evaluation on large collections.
|
|
41
|
+
- Prefer `firstOrNull()` over `first()` for safe access.
|
|
42
|
+
- Use destructuring: `val (name, age) = user`.
|
|
43
|
+
|
|
44
|
+
## Scope Functions
|
|
45
|
+
- `let`: null-safe chaining and local scoping.
|
|
46
|
+
- `apply`: configure object after creation.
|
|
47
|
+
- `also`: side effects (logging, validation) in chains.
|
|
48
|
+
- `run`: compute a result using receiver's context.
|
|
49
|
+
- `with`: multiple operations on an object without chaining.
|
|
50
|
+
- Avoid nesting scope functions more than 1 level deep.
|
|
51
|
+
|
|
52
|
+
## Formatting
|
|
53
|
+
- Use ktlint or detekt for automated formatting and linting.
|
|
54
|
+
- Use trailing commas in multi-line parameter/argument lists.
|
|
55
|
+
- Max line length: 120 characters (Kotlin convention).
|
|
56
|
+
- Use `when` expression over if-else chains for 3+ branches.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
language: kotlin
|
|
3
|
+
category: frameworks
|
|
4
|
+
version: "1.0.0"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Kotlin Frameworks
|
|
8
|
+
|
|
9
|
+
## Ktor (Server)
|
|
10
|
+
- Use routing DSL: `routing { get("/users") { call.respond(users) } }`.
|
|
11
|
+
- Use `install()` for plugins: ContentNegotiation, Authentication, CORS.
|
|
12
|
+
- Use `call.receive<T>()` for typed request body parsing with kotlinx.serialization.
|
|
13
|
+
- Use `StatusPages` plugin for centralized error handling.
|
|
14
|
+
- Use `Routing` with nested `route("/api/v1") { }` blocks for URL grouping.
|
|
15
|
+
|
|
16
|
+
## Ktor (Client)
|
|
17
|
+
- Use `HttpClient` with engine configuration (CIO, OkHttp, Apache).
|
|
18
|
+
- Use `install(ContentNegotiation) { json() }` for JSON serialization.
|
|
19
|
+
- Use `client.get<T>()` with reified type for typed responses.
|
|
20
|
+
- Use `HttpTimeout` plugin for connection and request timeouts.
|
|
21
|
+
- Close `HttpClient` when done or use DI lifecycle management.
|
|
22
|
+
|
|
23
|
+
## Spring Boot (Kotlin)
|
|
24
|
+
- Use constructor injection (Kotlin classes are `final` by default).
|
|
25
|
+
- Apply `kotlin-spring` plugin for open classes (required for proxying).
|
|
26
|
+
- Use `@ConfigurationProperties` with data classes for typed config.
|
|
27
|
+
- Use `WebFlux` with coroutines: `coRouter { }` and `suspend` handler functions.
|
|
28
|
+
- Use `spring-boot-starter-validation` with `@Valid` on Kotlin data classes.
|
|
29
|
+
|
|
30
|
+
## Exposed (ORM)
|
|
31
|
+
- Use DSL API for type-safe queries: `Users.select { Users.name eq "Ada" }`.
|
|
32
|
+
- Use DAO API for Active Record-style: `User.find { Users.age greaterEq 18 }`.
|
|
33
|
+
- Wrap database operations in `transaction { }` blocks.
|
|
34
|
+
- Use `SchemaUtils.create(Users)` for schema management in development.
|
|
35
|
+
|
|
36
|
+
## kotlinx.serialization
|
|
37
|
+
- Use `@Serializable` annotation on data classes for compile-time serialization.
|
|
38
|
+
- Use `@SerialName("field_name")` for JSON field name mapping.
|
|
39
|
+
- Use `Json { ignoreUnknownKeys = true }` for lenient deserialization.
|
|
40
|
+
- Use polymorphic serialization with `sealed class` and `@Polymorphic`.
|
|
41
|
+
- Prefer `kotlinx.serialization` over Jackson for pure Kotlin projects.
|
|
42
|
+
|
|
43
|
+
## Koin (DI)
|
|
44
|
+
- Define modules: `module { single { UserService(get()) } }`.
|
|
45
|
+
- Use `by inject<T>()` for lazy injection in Android/Ktor.
|
|
46
|
+
- Use `factory { }` for new instance per injection, `single { }` for singleton.
|
|
47
|
+
- Use `checkModules()` in tests to verify DI graph completeness.
|
|
48
|
+
|
|
49
|
+
## Compose (Multiplatform UI)
|
|
50
|
+
- Use `@Composable` functions for UI components. Keep them stateless.
|
|
51
|
+
- Use `remember { }` and `mutableStateOf()` for local state.
|
|
52
|
+
- Hoist state to callers: pass state down, events up.
|
|
53
|
+
- Use `LaunchedEffect` for side effects tied to composition lifecycle.
|
|
54
|
+
- Use `ViewModel` with `StateFlow` for screen-level state management.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
language: kotlin
|
|
3
|
+
category: patterns
|
|
4
|
+
version: "1.0.0"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Kotlin Patterns
|
|
8
|
+
|
|
9
|
+
## Error Handling
|
|
10
|
+
- Use `Result<T>` for operations that can fail without exceptions.
|
|
11
|
+
- Use `runCatching { }` to wrap exception-throwing code into `Result`.
|
|
12
|
+
- Use `sealed class` hierarchies for domain errors: `sealed class AppError`.
|
|
13
|
+
- Prefer `fold()`, `getOrElse()`, `getOrNull()` over `getOrThrow()`.
|
|
14
|
+
- Use `require()` / `check()` for preconditions; they throw `IllegalArgumentException` / `IllegalStateException`.
|
|
15
|
+
|
|
16
|
+
## Coroutines
|
|
17
|
+
- Use `suspend` functions for sequential async operations.
|
|
18
|
+
- Use `coroutineScope { }` for structured concurrency with parallel work.
|
|
19
|
+
- Use `async { }` + `await()` for concurrent independent operations.
|
|
20
|
+
- Use `supervisorScope { }` when child failures should not cancel siblings.
|
|
21
|
+
- Use `withContext(Dispatchers.IO)` for blocking I/O in coroutine context.
|
|
22
|
+
- Use `flow { }` for cold asynchronous streams. Collect in lifecycle-aware scope.
|
|
23
|
+
|
|
24
|
+
## Flow Patterns
|
|
25
|
+
- Use `stateIn()` and `shareIn()` to convert cold flows to hot shared state.
|
|
26
|
+
- Use `combine()` to merge multiple flows into derived state.
|
|
27
|
+
- Use `flatMapLatest` for search-as-you-type patterns (cancel previous).
|
|
28
|
+
- Use `catch { }` operator for upstream error handling in flows.
|
|
29
|
+
- Use `flowOn(Dispatchers.IO)` to shift upstream execution context.
|
|
30
|
+
|
|
31
|
+
## Sealed Hierarchies
|
|
32
|
+
- Use `sealed interface` over `sealed class` when no shared state is needed.
|
|
33
|
+
- Use `when` expressions exhaustively on sealed types (compiler-enforced).
|
|
34
|
+
- Combine sealed types with data classes for typed state machines.
|
|
35
|
+
- Use sealed hierarchies for API responses: `Success<T>`, `Error`, `Loading`.
|
|
36
|
+
|
|
37
|
+
## Delegation
|
|
38
|
+
- Use `by lazy { }` for thread-safe lazy initialization.
|
|
39
|
+
- Use `by map` for delegated properties backed by a `Map`.
|
|
40
|
+
- Use class delegation (`class Foo : Bar by impl`) to favor composition.
|
|
41
|
+
- Use `observable` / `vetoable` delegates for reactive property changes.
|
|
42
|
+
|
|
43
|
+
## Builder Patterns
|
|
44
|
+
- Use DSL-style builders with `@DslMarker` annotation to prevent scope leakage.
|
|
45
|
+
- Use trailing lambda syntax for configuration blocks.
|
|
46
|
+
- Use `apply { }` for inline object configuration without a dedicated builder.
|
|
47
|
+
- Use `buildList { }`, `buildMap { }`, `buildString { }` for collection construction.
|
|
48
|
+
|
|
49
|
+
## Anti-Patterns
|
|
50
|
+
- Overusing `!!`: masks null-safety guarantees. Use safe calls or require.
|
|
51
|
+
- Nesting scope functions: `foo.let { it.also { ... }.run { } }` -- flatten logic.
|
|
52
|
+
- Blocking the main thread: use `withContext(Dispatchers.IO)` for I/O.
|
|
53
|
+
- Using `GlobalScope.launch`: leaks coroutines. Use structured concurrency.
|
|
54
|
+
- Mutable shared state without synchronization: use `Mutex` or `StateFlow`.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
language: kotlin
|
|
3
|
+
category: security
|
|
4
|
+
version: "1.0.0"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Kotlin Security
|
|
8
|
+
|
|
9
|
+
## Input Validation
|
|
10
|
+
- Validate all inputs at API boundaries using Bean Validation or manual checks.
|
|
11
|
+
- Use `require()` for argument validation: `require(age > 0) { "Age must be positive" }`.
|
|
12
|
+
- Use data class `init` blocks for domain validation on construction.
|
|
13
|
+
- Never trust client-provided IDs. Verify resource ownership server-side.
|
|
14
|
+
- Sanitize strings before using in HTML, SQL, or shell commands.
|
|
15
|
+
|
|
16
|
+
## Null Safety as Security
|
|
17
|
+
- Kotlin's null safety prevents null pointer exceptions. Do not circumvent with `!!`.
|
|
18
|
+
- Use `?.` and `?:` chains for safe fallback values at boundaries.
|
|
19
|
+
- Treat Java interop as untrusted: platform types can still be null.
|
|
20
|
+
- Use `@Nullable` / `@NotNull` annotations on Java code consumed by Kotlin.
|
|
21
|
+
|
|
22
|
+
## SQL Injection
|
|
23
|
+
- Use Exposed DSL or JPA with parameterized queries. Never concatenate input.
|
|
24
|
+
- Use `PreparedStatement` if writing raw JDBC.
|
|
25
|
+
- Use `CriteriaBuilder` or Exposed conditions for dynamic query construction.
|
|
26
|
+
- Audit `@Query(nativeQuery = true)` for parameter interpolation risks.
|
|
27
|
+
|
|
28
|
+
## Serialization
|
|
29
|
+
- Use `kotlinx.serialization` with `@Serializable` for compile-time safety.
|
|
30
|
+
- Use `Json { ignoreUnknownKeys = true }` but validate after deserialization.
|
|
31
|
+
- Never use Java `ObjectInputStream` for deserialization (RCE risk).
|
|
32
|
+
- Restrict polymorphic deserialization to known sealed class subtypes.
|
|
33
|
+
|
|
34
|
+
## Authentication
|
|
35
|
+
- Use Spring Security or Ktor Authentication plugin. Do not roll your own.
|
|
36
|
+
- Hash passwords with BCrypt or Argon2. Never store plaintext.
|
|
37
|
+
- Use short-lived JWTs (15 min) with refresh token rotation.
|
|
38
|
+
- Validate JWT signature, issuer, audience, and expiration on every request.
|
|
39
|
+
|
|
40
|
+
## Coroutine Security
|
|
41
|
+
- Use `withTimeout()` to prevent unbounded coroutine execution (DoS vector).
|
|
42
|
+
- Use `Mutex` for critical sections. Do not use `synchronized` in suspend functions.
|
|
43
|
+
- Propagate security context through `CoroutineContext` elements.
|
|
44
|
+
- Cancel coroutine scopes on authentication failure or session expiry.
|
|
45
|
+
|
|
46
|
+
## Secrets Management
|
|
47
|
+
- Use environment variables or Vault for secrets. Never hardcode.
|
|
48
|
+
- Use `@ConfigurationProperties` with injected secrets, not string literals.
|
|
49
|
+
- Never log request headers containing Authorization tokens.
|
|
50
|
+
- Use separate configuration profiles for dev/staging/prod secrets.
|
|
51
|
+
|
|
52
|
+
## Dependencies
|
|
53
|
+
- Use Dependabot or Renovate for automated dependency updates.
|
|
54
|
+
- Run OWASP Dependency-Check or Gradle `dependencyCheckAnalyze`.
|
|
55
|
+
- Audit transitive dependencies with `gradle dependencies`.
|
|
56
|
+
- Pin dependency versions. Avoid dynamic versions like `1.+`.
|
|
57
|
+
|
|
58
|
+
## Logging
|
|
59
|
+
- Use parameterized logging: `logger.info("User {} logged in", userId)`.
|
|
60
|
+
- Never log passwords, tokens, or PII.
|
|
61
|
+
- Sanitize user input before logging to prevent log injection.
|
|
62
|
+
- Use structured logging (JSON) for machine-parseable audit trails.
|