tally-cli 0.1.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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,535 @@
1
+ # tally
2
+
3
+ [![codecov](https://codecov.io/gh/tinovyatkin/tally/graph/badge.svg?token=J3vK0hyLkf)](https://codecov.io/gh/tinovyatkin/tally)
4
+
5
+ tally keeps Dockerfiles and Containerfiles clean, modern, and consistent — using BuildKit's own parser and checks (the same foundation behind
6
+ `docker buildx`) plus safe auto-fixes. It runs fast, doesn't require Docker Desktop or a daemon, and fits neatly into CI. If that sounds like your
7
+ workflow, try `tally check .`.
8
+
9
+ ```bash
10
+ # Lint everything in the repo (recursive)
11
+ tally check .
12
+
13
+ # Apply all safe fixes automatically
14
+ tally check --fix Dockerfile
15
+ ```
16
+
17
+ ## Why tally?
18
+
19
+ Dockerfile linting usually means picking a compromise:
20
+
21
+ - **Hadolint** is popular and battle-tested, but it uses its own Dockerfile parser, so support for newer BuildKit features can lag behind. It also
22
+ is commonly consumed as a prebuilt binary, and it focuses on reporting — not fixing.
23
+ - **`docker buildx --check`** runs Docker's official BuildKit checks, but it requires the Docker/buildx toolchain and can be heavier than a pure
24
+ static linter (and not always available if you're using Podman/Finch/other runtimes).
25
+
26
+ tally exists to bring modern linter ergonomics to container builds:
27
+
28
+ - **BuildKit-native parsing**: understands modern syntax like heredocs, `RUN --mount=...`, and `ADD --checksum=...`.
29
+ - **Fixes, not just findings**: applies safe, mechanical fixes automatically (`--fix`), with per-rule control when you need it.
30
+ - **Easy to install anywhere**: available via Homebrew, Go, npm, pip, and RubyGems — so it can flow through your existing artifact mirrors.
31
+ - **Container ecosystem friendly**: supports Dockerfile/Containerfile conventions and `.dockerignore`/`.containerignore`.
32
+ - **A growing ruleset**: combines official BuildKit checks, Hadolint-compatible rules, and tally-specific rules.
33
+
34
+ Roadmap: editor integrations (VS Code, Zed), more auto-fixes, and higher-level rules (cache & tmpfs mount recommendations, tooling-aware checks for
35
+ uv/bun, line-length and layer optimizations).
36
+
37
+ ## Supported Rules
38
+
39
+ tally integrates rules from multiple sources:
40
+
41
+ <!-- BEGIN RULES_TABLE -->
42
+
43
+ | Source | Rules | Description |
44
+ | --------------------------------------------------------------- | -------- | --------------------------------------------------------------------------------------------- |
45
+ | **[BuildKit](https://docs.docker.com/reference/build-checks/)** | 22 rules | Docker's official Dockerfile checks (automatically captured) |
46
+ | **tally** | 3 rules | Custom rules including secret detection with [gitleaks](https://github.com/gitleaks/gitleaks) |
47
+ | **[Hadolint](https://github.com/hadolint/hadolint)** | 22 rules | Hadolint-compatible Dockerfile rules (expanding) |
48
+
49
+ <!-- END RULES_TABLE -->
50
+
51
+ **See [RULES.md](RULES.md) for the complete rules reference.**
52
+
53
+ ## Installation
54
+
55
+ ### Homebrew (macOS/Linux)
56
+
57
+ ```bash
58
+ brew install tinovyatkin/tap/tally
59
+ ```
60
+
61
+ ### NPM
62
+
63
+ ```bash
64
+ npm install -g tally-cli
65
+ ```
66
+
67
+ ### PyPI
68
+
69
+ ```bash
70
+ pip install tally-cli
71
+ ```
72
+
73
+ ### RubyGems
74
+
75
+ ```bash
76
+ gem install tally-cli
77
+ ```
78
+
79
+ ### Go
80
+
81
+ ```bash
82
+ go install github.com/tinovyatkin/tally@latest
83
+ ```
84
+
85
+ ### From Source
86
+
87
+ ```bash
88
+ git clone https://github.com/tinovyatkin/tally.git
89
+ cd tally
90
+ go build .
91
+ ```
92
+
93
+ ## Usage
94
+
95
+ ```bash
96
+ # Check a Dockerfile
97
+ tally check Dockerfile
98
+
99
+ # Check all Dockerfiles in current directory (recursive)
100
+ tally check .
101
+
102
+ # Check with glob patterns
103
+ tally check "**/*.Dockerfile"
104
+
105
+ # Exclude patterns
106
+ tally check --exclude "vendor/*" --exclude "test/*" .
107
+
108
+ # Check with max lines limit
109
+ tally check --max-lines 100 Dockerfile
110
+
111
+ # Output as JSON
112
+ tally check --format json Dockerfile
113
+
114
+ # Check multiple files
115
+ tally check Dockerfile.dev Dockerfile.prod
116
+
117
+ # Enable context-aware rules (e.g., copy-ignored-file)
118
+ tally check --context . Dockerfile
119
+ ```
120
+
121
+ ### File Discovery
122
+
123
+ When given a directory, tally recursively searches for Dockerfiles using these default patterns:
124
+
125
+ - `Dockerfile`
126
+ - `Dockerfile.*` (e.g., `Dockerfile.dev`, `Dockerfile.prod`)
127
+ - `*.Dockerfile` (e.g., `api.Dockerfile`, `frontend.Dockerfile`)
128
+ - `Containerfile` (Podman convention)
129
+ - `Containerfile.*`
130
+ - `*.Containerfile`
131
+
132
+ Use `--exclude` to filter out unwanted files:
133
+
134
+ ```bash
135
+ # Exclude vendor and test directories
136
+ tally check --exclude "vendor/*" --exclude "test/*" .
137
+
138
+ # Exclude all .bak files
139
+ tally check --exclude "*.bak" .
140
+ ```
141
+
142
+ ## Rules Overview
143
+
144
+ For the complete list of all supported rules, see **[RULES.md](RULES.md)**.
145
+
146
+ ### Context-Aware Rules
147
+
148
+ Some rules require build context awareness. Enable them with the `--context` flag:
149
+
150
+ ```bash
151
+ # Enable context-aware rules
152
+ tally check --context . Dockerfile
153
+ ```
154
+
155
+ **copy-ignored-file**: Detects when `COPY` or `ADD` commands reference files that would be excluded by `.dockerignore`. This helps catch mistakes
156
+ where files are copied but won't actually be included in the build.
157
+
158
+ ```dockerfile
159
+ # .dockerignore contains: *.log
160
+
161
+ # This will trigger a warning:
162
+ COPY app.log /app/ # File matches .dockerignore pattern
163
+
164
+ # Heredoc sources are exempt (they're inline, not from context):
165
+ COPY <<EOF /app/config.txt
166
+ inline content
167
+ EOF
168
+ ```
169
+
170
+ ## Ignoring Violations
171
+
172
+ You can suppress specific violations using inline comment directives.
173
+
174
+ ### Next-Line Directives
175
+
176
+ Suppress violations on the next line:
177
+
178
+ ```dockerfile
179
+ # tally ignore=StageNameCasing
180
+ FROM alpine AS Build
181
+ ```
182
+
183
+ ### Global Directives
184
+
185
+ Suppress violations throughout the entire file:
186
+
187
+ ```dockerfile
188
+ # tally global ignore=max-lines
189
+ FROM alpine
190
+ # ... rest of file is not checked for max-lines
191
+ ```
192
+
193
+ ### Multiple Rules
194
+
195
+ Suppress multiple rules with comma-separated values:
196
+
197
+ ```dockerfile
198
+ # tally ignore=StageNameCasing,DL3006
199
+ FROM Ubuntu AS Build
200
+ ```
201
+
202
+ ### Adding Reasons
203
+
204
+ Document why a rule is being ignored using `;reason=` (BuildKit-style separator):
205
+
206
+ ```dockerfile
207
+ # tally ignore=DL3006;reason=Using older base image for compatibility
208
+ FROM ubuntu:16.04
209
+
210
+ # tally global ignore=max-lines;reason=Generated file, size is expected
211
+ FROM alpine
212
+
213
+ # check=skip=StageNameCasing;reason=Legacy naming convention
214
+ FROM alpine AS Build
215
+ ```
216
+
217
+ Use `--require-reason` to enforce that all ignore directives include an explanation:
218
+
219
+ ```bash
220
+ tally check --require-reason Dockerfile
221
+ ```
222
+
223
+ Note: The `;reason=` syntax is a tally extension that works with all directive formats. BuildKit silently ignores the `reason` option.
224
+
225
+ ### Migration Compatibility
226
+
227
+ tally supports directive formats from other linters for easy migration:
228
+
229
+ ```dockerfile
230
+ # hadolint ignore=DL3006
231
+ FROM ubuntu
232
+
233
+ # hadolint global ignore=DL3008
234
+ FROM alpine
235
+
236
+ # check=skip=StageNameCasing
237
+ FROM alpine AS Build
238
+ ```
239
+
240
+ ### Suppressing All Rules
241
+
242
+ Use `all` to suppress all rules on a line:
243
+
244
+ ```dockerfile
245
+ # tally ignore=all
246
+ FROM Ubuntu AS Build
247
+ ```
248
+
249
+ ### CLI Options
250
+
251
+ | Flag | Description |
252
+ | -------------------------- | ---------------------------------------------------------- |
253
+ | `--no-inline-directives` | Disable processing of inline ignore directives |
254
+ | `--warn-unused-directives` | Warn about directives that don't suppress any violations |
255
+ | `--require-reason` | Warn about ignore directives without `reason=` explanation |
256
+
257
+ ### Configuration
258
+
259
+ Inline directive behavior can be configured in `.tally.toml`:
260
+
261
+ ```toml
262
+ [inline-directives]
263
+ enabled = true # Process inline directives (default: true)
264
+ warn-unused = false # Warn about unused directives (default: false)
265
+ validate-rules = false # Warn about unknown rule codes (default: false)
266
+ require-reason = false # Require reason= on all ignore directives (default: false)
267
+ ```
268
+
269
+ ## Configuration
270
+
271
+ tally supports configuration via TOML config files, environment variables, and CLI flags.
272
+
273
+ ### Config File
274
+
275
+ Create a `.tally.toml` or `tally.toml` file in your project:
276
+
277
+ ```toml
278
+ [output]
279
+ format = "text" # text, json, sarif, github-actions, markdown
280
+ path = "stdout" # stdout, stderr, or file path
281
+ show-source = true # Show source code snippets
282
+ fail-level = "style" # Minimum severity for exit code 1
283
+
284
+ # Rule selection (Ruff-style)
285
+ [rules]
286
+ include = ["buildkit/*", "tally/*"] # Enable rules by namespace or specific rule
287
+ exclude = ["buildkit/MaintainerDeprecated"] # Disable specific rules
288
+
289
+ # Per-rule configuration (severity, options)
290
+ [rules.tally.max-lines]
291
+ severity = "error"
292
+ max = 500
293
+ skip-blank-lines = true
294
+ skip-comments = true
295
+
296
+ [rules.buildkit.StageNameCasing]
297
+ severity = "info" # Downgrade severity
298
+
299
+ [rules.hadolint.DL3026]
300
+ severity = "warning"
301
+ trusted-registries = ["docker.io", "gcr.io"]
302
+ ```
303
+
304
+ ### Config File Discovery
305
+
306
+ tally uses cascading config discovery similar to [Ruff](https://docs.astral.sh/ruff/configuration/):
307
+
308
+ 1. Starting from the Dockerfile's directory, walks up the filesystem
309
+ 2. Stops at the first `.tally.toml` or `tally.toml` found
310
+ 3. Uses that config (no merging with parent configs)
311
+
312
+ This allows monorepo setups with per-directory configurations.
313
+
314
+ ### Priority Order
315
+
316
+ Configuration sources are applied in this order (highest priority first):
317
+
318
+ 1. **CLI flags** (`--max-lines 100`)
319
+ 2. **Environment variables** (`TALLY_RULES_MAX_LINES_MAX=100`)
320
+ 3. **Config file** (`.tally.toml` or `tally.toml`)
321
+ 4. **Built-in defaults**
322
+
323
+ ### Environment Variables
324
+
325
+ | Variable | Description |
326
+ | ---------------------------------------- | --------------------------------------------------------------------- |
327
+ | `TALLY_OUTPUT_FORMAT` | Output format (`text`, `json`, `sarif`, `github-actions`, `markdown`) |
328
+ | `TALLY_OUTPUT_PATH` | Output destination (`stdout`, `stderr`, or file path) |
329
+ | `TALLY_OUTPUT_SHOW_SOURCE` | Show source snippets (`true`/`false`) |
330
+ | `TALLY_OUTPUT_FAIL_LEVEL` | Minimum severity for non-zero exit |
331
+ | `NO_COLOR` | Disable colored output (standard env var) |
332
+ | `TALLY_EXCLUDE` | Glob pattern(s) to exclude files (comma-separated) |
333
+ | `TALLY_CONTEXT` | Build context directory for context-aware rules |
334
+ | `TALLY_RULES_MAX_LINES_MAX` | Maximum lines allowed |
335
+ | `TALLY_RULES_MAX_LINES_SKIP_BLANK_LINES` | Exclude blank lines (`true`/`false`) |
336
+ | `TALLY_RULES_MAX_LINES_SKIP_COMMENTS` | Exclude comments (`true`/`false`) |
337
+ | `TALLY_NO_INLINE_DIRECTIVES` | Disable inline directive processing (`true`/`false`) |
338
+ | `TALLY_INLINE_DIRECTIVES_WARN_UNUSED` | Warn about unused directives (`true`/`false`) |
339
+ | `TALLY_INLINE_DIRECTIVES_REQUIRE_REASON` | Require reason= on ignore directives (`true`/`false`) |
340
+
341
+ ### CLI Flags
342
+
343
+ ```bash
344
+ # Specify config file explicitly
345
+ tally check --config /path/to/.tally.toml Dockerfile
346
+
347
+ # Override max-lines from config
348
+ tally check --max-lines 200 Dockerfile
349
+
350
+ # Exclude blank lines and comments from count
351
+ tally check --max-lines 100 --skip-blank-lines --skip-comments Dockerfile
352
+ ```
353
+
354
+ ## Output Formats
355
+
356
+ tally supports multiple output formats for different use cases.
357
+
358
+ ### Text (default)
359
+
360
+ Human-readable output with colors and source code snippets:
361
+
362
+ ```bash
363
+ tally check Dockerfile
364
+ ```
365
+
366
+ ```text
367
+ WARNING: StageNameCasing - https://docs.docker.com/go/dockerfile/rule/stage-name-casing/
368
+ Stage name 'Builder' should be lowercase
369
+
370
+ Dockerfile:2
371
+ ────────────────────
372
+ 1 │ FROM alpine
373
+ >>>2 │ FROM ubuntu AS Builder
374
+ 3 │ RUN echo "hello"
375
+ ────────────────────
376
+ ```
377
+
378
+ ### JSON
379
+
380
+ Machine-readable format with summary statistics and scan metadata:
381
+
382
+ ```bash
383
+ tally check --format json Dockerfile
384
+ ```
385
+
386
+ The JSON output includes:
387
+
388
+ - `files`: Array of files with their violations
389
+ - `summary`: Aggregate statistics (total, errors, warnings, etc.)
390
+ - `files_scanned`: Total number of files scanned
391
+ - `rules_enabled`: Number of active rules (with `DefaultSeverity != "off"`)
392
+
393
+ ```json
394
+ {
395
+ "files": [
396
+ {
397
+ "file": "Dockerfile",
398
+ "violations": [
399
+ {
400
+ "location": {
401
+ "file": "Dockerfile",
402
+ "start": { "line": 2, "column": 0 }
403
+ },
404
+ "rule": "buildkit/StageNameCasing",
405
+ "message": "Stage name 'Builder' should be lowercase",
406
+ "severity": "warning",
407
+ "docUrl": "https://docs.docker.com/go/dockerfile/rule/stage-name-casing/"
408
+ }
409
+ ]
410
+ }
411
+ ],
412
+ "summary": {
413
+ "total": 1,
414
+ "errors": 0,
415
+ "warnings": 1,
416
+ "info": 0,
417
+ "style": 0,
418
+ "files": 1
419
+ },
420
+ "files_scanned": 1,
421
+ "rules_enabled": 35
422
+ }
423
+ ```
424
+
425
+ ### SARIF
426
+
427
+ [Static Analysis Results Interchange Format](https://docs.oasis-open.org/sarif/sarif/v2.1.0/) for CI/CD integration with GitHub Code Scanning, Azure DevOps, and other tools:
428
+
429
+ ```bash
430
+ tally check --format sarif Dockerfile > results.sarif
431
+ ```
432
+
433
+ ### GitHub Actions
434
+
435
+ Native GitHub Actions workflow command format for inline annotations:
436
+
437
+ ```bash
438
+ tally check --format github-actions Dockerfile
439
+ ```
440
+
441
+ ```text
442
+ ::warning file=Dockerfile,line=2,title=StageNameCasing::Stage name 'Builder' should be lowercase
443
+ ```
444
+
445
+ ### Markdown
446
+
447
+ Concise Markdown tables optimized for AI agents and token efficiency:
448
+
449
+ ```bash
450
+ tally check --format markdown Dockerfile
451
+ ```
452
+
453
+ ```markdown
454
+ **2 issues** in `Dockerfile`
455
+
456
+ | Line | Issue |
457
+ | ---- | ------------------------------------------- |
458
+ | 10 | ❌ Use absolute WORKDIR |
459
+ | 2 | ⚠️ Stage name 'Builder' should be lowercase |
460
+ ```
461
+
462
+ Features:
463
+
464
+ - Summary upfront with issue counts
465
+ - Sorted by severity (errors first)
466
+ - Emoji indicators: ❌ error, ⚠️ warning, ℹ️ info, 💅 style
467
+ - No rule codes or doc URLs (token-efficient)
468
+ - Multi-file support with File column when needed
469
+
470
+ ### Output Options
471
+
472
+ | Flag | Description |
473
+ | --------------- | -------------------------------------------------------------------- |
474
+ | `--format, -f` | Output format: `text`, `json`, `sarif`, `github-actions`, `markdown` |
475
+ | `--output, -o` | Output destination: `stdout`, `stderr`, or file path |
476
+ | `--no-color` | Disable colored output (also respects `NO_COLOR` env var) |
477
+ | `--show-source` | Show source code snippets (default: true) |
478
+ | `--hide-source` | Hide source code snippets |
479
+
480
+ ### Exit Codes
481
+
482
+ | Code | Meaning |
483
+ | ---- | ------------------------------------------------- |
484
+ | `0` | No violations (or below `--fail-level` threshold) |
485
+ | `1` | Violations found at or above `--fail-level` |
486
+ | `2` | Parse or configuration error |
487
+
488
+ ### Fail Level
489
+
490
+ Control which severity levels cause a non-zero exit code:
491
+
492
+ ```bash
493
+ # Fail only on errors (ignore warnings)
494
+ tally check --fail-level error Dockerfile
495
+
496
+ # Never fail (useful for CI reporting without blocking)
497
+ tally check --fail-level none --format sarif Dockerfile > results.sarif
498
+
499
+ # Fail on any violation including style issues (default behavior)
500
+ tally check --fail-level style Dockerfile
501
+ ```
502
+
503
+ Available levels (from most to least severe): `error`, `warning`, `info`, `style` (default), `none`
504
+
505
+ ## Development
506
+
507
+ ### Running Tests
508
+
509
+ ```bash
510
+ # Run all tests
511
+ make test
512
+
513
+ # Run linting
514
+ make lint
515
+
516
+ # Run copy/paste detection (CPD)
517
+ make cpd
518
+ ```
519
+
520
+ ### Code Quality
521
+
522
+ This project uses:
523
+
524
+ - **golangci-lint** for Go linting
525
+ - **PMD CPD** for copy/paste detection (minimum 100 tokens)
526
+
527
+ Copy/paste detection runs automatically in CI and helps identify duplicate code patterns.
528
+
529
+ ## Contributing
530
+
531
+ See [CLAUDE.md](CLAUDE.md) for development guidelines.
532
+
533
+ ## License
534
+
535
+ Apache-2.0
package/bin/index.js ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require('child_process');
4
+ const { getExePath } = require('../get-exe');
5
+
6
+ const command_args = process.argv.slice(2);
7
+
8
+ const child = spawn(
9
+ getExePath(),
10
+ command_args,
11
+ { stdio: "inherit" });
12
+
13
+ child.on('error', function (err) {
14
+ console.error(`Failed to execute binary: ${err.message}`);
15
+ process.exit(1);
16
+ });
17
+
18
+ child.on('close', function (code) {
19
+ if (code !== 0) {
20
+ process.exit(code);
21
+ }
22
+ });
package/get-exe.js ADDED
@@ -0,0 +1,18 @@
1
+ function getExePath() {
2
+ // Detect OS
3
+ // https://nodejs.org/api/process.html#process_process_platform
4
+ let os = process.platform;
5
+ let extension = "";
6
+ if (["win32", "cygwin"].includes(process.platform)) {
7
+ os = "windows";
8
+ extension = ".exe";
9
+ }
10
+
11
+ // Detect architecture
12
+ // https://nodejs.org/api/process.html#process_process_arch
13
+ let arch = process.arch;
14
+
15
+ return require.resolve(`@contino/tally-${os}-${arch}/bin/tally${extension}`);
16
+ }
17
+
18
+ exports.getExePath = getExePath;
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "tally-cli",
3
+ "version": "0.1.0",
4
+ "description": "A fast, configurable linter for Dockerfiles and Containerfiles",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/tinovyatkin/tally.git"
8
+ },
9
+ "main": "bin/index.js",
10
+ "files": [
11
+ "postinstall.js",
12
+ "get-exe.js"
13
+ ],
14
+ "bin": {
15
+ "tally": "bin/index.js"
16
+ },
17
+ "keywords": [
18
+ "docker",
19
+ "dockerfile",
20
+ "containerfile",
21
+ "linter",
22
+ "lint",
23
+ "container"
24
+ ],
25
+ "author": "tinovyatkin",
26
+ "license": "Apache-2.0",
27
+ "bugs": {
28
+ "url": "https://github.com/tinovyatkin/tally/issues"
29
+ },
30
+ "homepage": "https://github.com/tinovyatkin/tally#readme",
31
+ "optionalDependencies": {
32
+ "@contino/tally-darwin-arm64": "0.1.0",
33
+ "@contino/tally-darwin-x64": "0.1.0",
34
+ "@contino/tally-linux-arm64": "0.1.0",
35
+ "@contino/tally-linux-x64": "0.1.0",
36
+ "@contino/tally-windows-arm64": "0.1.0",
37
+ "@contino/tally-windows-x64": "0.1.0",
38
+ "@contino/tally-freebsd-x64": "0.1.0"
39
+ },
40
+ "scripts": {
41
+ "postinstall": "node postinstall.js"
42
+ }
43
+ }
package/postinstall.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+
3
+ // This file is intentionally empty to prevent postinstall errors
4
+ // when optional dependencies are not installed