-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
87 lines (79 loc) · 2.83 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
87 lines (79 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
exclude: ^charts/.*/templates/.*\.yaml$
- id: check-added-large-files
- id: check-merge-conflict
- repo: local
hooks:
- id: cargo-fmt
name: cargo fmt
entry: cargo fmt --all --check
language: system
types: [rust]
pass_filenames: false
- id: cargo-clippy
name: cargo clippy
entry: env K8S_OPENAPI_ENABLED_VERSION=1.30 cargo clippy --workspace --all-targets --all-features -- -D warnings
language: system
types: [rust]
pass_filenames: false
- id: cargo-test
name: cargo test
entry: env K8S_OPENAPI_ENABLED_VERSION=1.30 cargo test --workspace --all-features
language: system
types: [rust]
pass_filenames: false
stages: [pre-push]
# Security-focused hooks
- id: cargo-deny
name: cargo deny (dependency security)
entry: cargo deny check
language: system
files: '(Cargo\.(toml|lock)|deny\.toml)$'
pass_filenames: false
- id: cargo-audit
name: cargo audit (vulnerability scan)
entry: bash -c 'cargo audit --version >/dev/null 2>&1 || echo "cargo-audit not installed, skipping"; cargo audit || echo "Security advisories found (check .cargo/audit.toml for justified exceptions)"'
language: system
files: '(Cargo\.(toml|lock)|\.cargo/audit\.toml)$'
pass_filenames: false
- id: check-security-sensitive
name: Check for security-sensitive content
entry: bash -c 'if grep -r -n -E "(password|secret|private_key|api_key)\s*=" --include="*.rs" --include="*.toml" --exclude-dir=target .; then echo "Potential hardcoded secrets found - please review"; exit 1; fi'
language: system
pass_filenames: false
- id: check-stale-docs
name: check stale docs
entry: cargo run --quiet --bin doc-check --
language: system
# Run whenever Rust source, docs, or the coverage config changes.
files: >-
(?x)^(
src/.*\.rs|
docs/.*\.md|
doc-coverage\.toml|
\.doc-hashes\.toml|
Makefile|
Cargo\.toml|
build\.rs|
charts/.*|
examples/.*|
config/.*|
benchmarks/.*|
formal_verification/.*|
tests/.*\.rs
)$
pass_filenames: false
# Only warn locally — CI enforces the hard failure.
args: ["--warn-only", "status"]
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1
hooks:
- id: yamllint
args: [-c=.yamllint.yml]
exclude: ^charts/.*/templates/.*\.yaml$