lockly 0.1.0__tar.gz

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.
Files changed (38) hide show
  1. lockly-0.1.0/LICENSE +201 -0
  2. lockly-0.1.0/PKG-INFO +179 -0
  3. lockly-0.1.0/README.md +150 -0
  4. lockly-0.1.0/lockly/__init__.py +9 -0
  5. lockly-0.1.0/lockly/__main__.py +3 -0
  6. lockly-0.1.0/lockly/assets/jetbrains-mono-LICENSE.txt +93 -0
  7. lockly-0.1.0/lockly/assets/jetbrains-mono-var.woff2 +0 -0
  8. lockly-0.1.0/lockly/assets/report.html +472 -0
  9. lockly-0.1.0/lockly/assets/space-grotesk-LICENSE.txt +93 -0
  10. lockly-0.1.0/lockly/assets/space-grotesk-var.woff2 +0 -0
  11. lockly-0.1.0/lockly/cli.py +330 -0
  12. lockly-0.1.0/lockly/cvss.py +229 -0
  13. lockly-0.1.0/lockly/cvss4_data.py +101 -0
  14. lockly-0.1.0/lockly/diff.py +329 -0
  15. lockly-0.1.0/lockly/enrich.py +346 -0
  16. lockly-0.1.0/lockly/git.py +96 -0
  17. lockly-0.1.0/lockly/html.py +178 -0
  18. lockly-0.1.0/lockly/licenses.py +150 -0
  19. lockly-0.1.0/lockly/miniyaml.py +184 -0
  20. lockly-0.1.0/lockly/model.py +58 -0
  21. lockly-0.1.0/lockly/parsers/__init__.py +74 -0
  22. lockly-0.1.0/lockly/parsers/native.py +106 -0
  23. lockly-0.1.0/lockly/parsers/npm.py +245 -0
  24. lockly-0.1.0/lockly/parsers/python.py +166 -0
  25. lockly-0.1.0/lockly/py.typed +0 -0
  26. lockly-0.1.0/lockly/render.py +250 -0
  27. lockly-0.1.0/lockly/versions.py +57 -0
  28. lockly-0.1.0/lockly.egg-info/PKG-INFO +179 -0
  29. lockly-0.1.0/lockly.egg-info/SOURCES.txt +36 -0
  30. lockly-0.1.0/lockly.egg-info/dependency_links.txt +1 -0
  31. lockly-0.1.0/lockly.egg-info/entry_points.txt +2 -0
  32. lockly-0.1.0/lockly.egg-info/requires.txt +3 -0
  33. lockly-0.1.0/lockly.egg-info/top_level.txt +1 -0
  34. lockly-0.1.0/pyproject.toml +57 -0
  35. lockly-0.1.0/setup.cfg +4 -0
  36. lockly-0.1.0/tests/test_cli.py +149 -0
  37. lockly-0.1.0/tests/test_diff.py +229 -0
  38. lockly-0.1.0/tests/test_parsers.py +118 -0
lockly-0.1.0/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.
lockly-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,179 @@
1
+ Metadata-Version: 2.4
2
+ Name: lockly
3
+ Version: 0.1.0
4
+ Summary: Explain lockfile changes in a pull request: what moved, and which changes deserve a look (install scripts, new publishers, fresh releases, vulnerabilities)
5
+ Author-email: Colin Moynes <dev@fullstackspectrum.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/fullstackspectrum/lockly
8
+ Project-URL: Issues, https://github.com/fullstackspectrum/lockly/issues
9
+ Keywords: lockfile,dependencies,supply-chain,security,npm,pypi,cargo,go,pull-request,code-review
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: System Administrators
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Security
21
+ Classifier: Topic :: Software Development :: Quality Assurance
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.11
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=7.0; extra == "dev"
28
+ Dynamic: license-file
29
+
30
+ [![Lockly: what changed in the lockfile, and why it matters.](https://raw.githubusercontent.com/fullstackspectrum/lockly/main/docs/brand/readme-banner.png)](https://github.com/fullstackspectrum/lockly)
31
+
32
+ [![CI](https://img.shields.io/github/actions/workflow/status/fullstackspectrum/lockly/build.yml?branch=main&style=for-the-badge&logo=githubactions&logoColor=white&label=CI&color=4f8cff&labelColor=10151d)](https://github.com/fullstackspectrum/lockly/actions/workflows/build.yml)
33
+ [![PyPI](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fpypi.org%2Fpypi%2Flockly%2Fjson&query=%24.info.version&prefix=v&label=pypi&style=for-the-badge&logo=pypi&logoColor=white&color=8fb4ff&labelColor=10151d)](https://pypi.org/project/lockly/)
34
+ [![Python](https://img.shields.io/badge/python-3.11%2B-f5c84c?style=for-the-badge&logo=python&logoColor=white&labelColor=10151d)](https://pypi.org/project/lockly/)
35
+ [![License](https://img.shields.io/badge/license-Apache--2.0-646f7f?style=for-the-badge&labelColor=10151d)](https://github.com/fullstackspectrum/lockly/blob/main/LICENSE)
36
+
37
+ # Lockly
38
+
39
+ **What changed in the lockfile, and why it matters.**
40
+
41
+ A dependency bump can change a few lines of `package.json` and thousands of lines of `package-lock.json`. Nobody reviews the second part. Lockly does: it reads the lockfile before and after a change, lists what moved, and flags the changes a reviewer should actually stop for:
42
+
43
+ - **Install scripts:** a package that now runs code when it's installed, the most common route for npm malware.
44
+ - **A new publisher:** a release published by an account new to the package, or no longer through trusted publishing. That's what an account takeover looks like.
45
+ - **Lost provenance:** the release before had a provenance attestation, this one doesn't.
46
+ - **Fresh releases and packages:** a version published in the last few days, or a package that's only weeks old. Most malicious releases are caught and pulled within days.
47
+ - **Changed contents or sources:** the same version with a different hash, or a package suddenly coming from git, a URL or another registry.
48
+ - **Known vulnerabilities** in the new versions, from [OSV](https://osv.dev), and the ones an upgrade fixes.
49
+ - **Deprecations, yanks and licence changes**, including new copyleft terms.
50
+
51
+ It reads **npm, Yarn (classic and Berry), pnpm, uv, Poetry, Pipenv, Go modules and Cargo** lockfiles, and runs on every pull request as a single comment that updates in place.
52
+
53
+ Lockly has no runtime dependencies and needs Python 3.11 or later.
54
+
55
+ > Lockly is a sibling of [Vulnly](https://github.com/fullstackspectrum/Vulnly), [Sbomly](https://github.com/fullstackspectrum/sbomly) and [Basely](https://github.com/fullstackspectrum/basely), and part of [Full-Stack-Spectrum](https://fullstackspectrum.com/): small open-source tools that turn noisy supply chain data into decisions.
56
+
57
+ ![Terminal output from lockly diff](https://raw.githubusercontent.com/fullstackspectrum/lockly/main/docs/screenshots/terminal.png)
58
+
59
+ ## On every pull request
60
+
61
+ ```yaml
62
+ name: Lockfile review
63
+ on: pull_request
64
+
65
+ permissions:
66
+ contents: read
67
+ pull-requests: write # to post the comment
68
+
69
+ jobs:
70
+ lockly:
71
+ runs-on: ubuntu-latest
72
+ steps:
73
+ - uses: actions/checkout@v4
74
+ - uses: fullstackspectrum/lockly@v0
75
+ with:
76
+ fail-on: install-script,publisher,hash
77
+ ```
78
+
79
+ The Action compares the pull request with its base, posts the review as one comment, and edits that comment on every push instead of adding new ones. It also writes the review to the job summary. Pull requests from forks get a read-only token, so there the comment is skipped with a warning and the job summary still has everything.
80
+
81
+ | Input | Default | |
82
+ | --- | --- | --- |
83
+ | `fail-on` | | finding types that fail the check (see below) |
84
+ | `base` | the PR's base commit | git ref to compare against |
85
+ | `paths` | whole repository | space-separated paths to look for lockfiles in |
86
+ | `offline` | `false` | `true` skips registry and OSV lookups |
87
+ | `min-age` | `3` | flag versions published less than this many days ago |
88
+ | `comment` | `true` | post the PR comment |
89
+ | `html`, `markdown`, `json` | `lockly-*` | where to write the reports, e.g. for an artifact upload |
90
+
91
+ ## Install
92
+
93
+ ```bash
94
+ pipx install lockly # or: pip install lockly
95
+ brew install fullstackspectrum/lockly/lockly
96
+ ```
97
+
98
+ There's also a container image for comparing two lockfile files. It has no git, so for `--base` use pip, Homebrew or the Action:
99
+
100
+ ```bash
101
+ docker run --rm -t -v "$PWD:/data" fullstackspectrum/lockly diff old/package-lock.json package-lock.json
102
+ ```
103
+
104
+ ## Usage
105
+
106
+ Compare every lockfile changed on your branch:
107
+
108
+ ```bash
109
+ lockly diff --base origin/main
110
+ ```
111
+
112
+ Lockly compares against the merge base, as a pull request does, so changes that landed on `main` since you branched don't show up. Without `--head` it reads the working tree, including lockfiles you haven't committed yet.
113
+
114
+ Or compare two files:
115
+
116
+ ```bash
117
+ lockly diff old/uv.lock uv.lock
118
+ ```
119
+
120
+ Write reports, and gate CI:
121
+
122
+ ```bash
123
+ lockly diff --base main --markdown comment.md --html report.html --json review.json
124
+ lockly diff --base main --fail-on install-script,publisher,hash
125
+ ```
126
+
127
+ ![Lockly HTML report](https://raw.githubusercontent.com/fullstackspectrum/lockly/main/docs/screenshots/report.png)
128
+
129
+ ## Lockfiles
130
+
131
+ | File | Ecosystem | Notes |
132
+ | --- | --- | --- |
133
+ | `package-lock.json`, `npm-shrinkwrap.json` | npm | lockfile v1 to v3; records licences and install scripts |
134
+ | `yarn.lock` | npm | Yarn classic and Berry; reads `package.json` to tell direct dependencies |
135
+ | `pnpm-lock.yaml` | npm | pnpm 5.4 to 9 (pnpm 10's two-document files too) |
136
+ | `uv.lock` | PyPI | records upload times, so release age needs no lookup |
137
+ | `poetry.lock` | PyPI | reads `pyproject.toml` to tell direct dependencies |
138
+ | `Pipfile.lock` | PyPI | reads `Pipfile` to tell direct dependencies |
139
+ | `go.mod` | Go | Go's lockfile in effect since 1.17; reads `go.sum` for hashes and follows `replace` directives |
140
+ | `Cargo.lock` | crates.io | |
141
+
142
+ ## Findings
143
+
144
+ | Type | Flags | Needs lookups |
145
+ | --- | --- | --- |
146
+ | `hash` | same version, different contents (compared only within one hash algorithm) | |
147
+ | `install-script` | a package that runs a script at install time, new or newly | npm lockfiles record it; other npm formats look it up |
148
+ | `publisher` | a release by an account new to the package, or that left trusted publishing | npm, crates.io |
149
+ | `provenance` | the previous release had a provenance attestation; this one doesn't | npm |
150
+ | `source` | a package from git, a URL, a path or another registry, or a changed source | |
151
+ | `new-package` | an added package first published less than `--new-package-days` (30) ago | yes |
152
+ | `young` | a version published less than `--min-age` (3) days ago | yes, except uv |
153
+ | `vulnerable` | the new version has known vulnerabilities | OSV |
154
+ | `deprecated` | deprecated (npm) or yanked (PyPI, crates.io) | yes |
155
+ | `copyleft` | a licence that brings in copyleft terms | npm lockfiles have licences; others look them up |
156
+ | `license` | a licence changed between copyleft and permissive terms (other changes are shown as info) | as above |
157
+
158
+ Publisher findings compare a release with **the release just before it in the registry**, not with whatever version you were on. A maintainer of the previous release taking a turn isn't flagged; an account new to the package is. Moving to trusted publishing is shown as information, since it's an improvement.
159
+
160
+ `--fail-on` takes any of these, or `any`. Exit codes: `0` passed, `1` a `--fail-on` type was found, `2` bad usage, or a lockfile or git ref that can't be read.
161
+
162
+ ## Network use
163
+
164
+ **By default Lockly looks things up**: the npm registry, PyPI, crates.io, the Go module proxy and OSV, for the packages that changed and nothing else. Responses are cached for a day in `~/.cache/lockly` (or `$LOCKLY_CACHE_DIR`), each request gives up after 5 seconds without a response, and crates.io's limit of one request a second is respected. If a lookup fails, the review still runs and says what it couldn't check.
165
+
166
+ `--offline` (or `LOCKLY_OFFLINE=1`) makes no requests at all: you get the diff, hashes, install scripts and licences the lockfile records, sources, and uv's release dates. The HTML report itself never makes network requests.
167
+
168
+ ## Development
169
+
170
+ ```bash
171
+ uv venv -p 3.14 && uv pip install -e ".[dev]"
172
+ .venv/bin/python -m pytest -q # offline: no test reaches a registry
173
+ .venv/bin/python docs/screenshots/src/render.py # README screenshots (network, Chrome)
174
+ ./docs/brand/src/render.sh # README banner and social preview
175
+ ```
176
+
177
+ ## License
178
+
179
+ Apache-2.0. The embedded Space Grotesk and JetBrains Mono fonts are under the SIL Open Font License 1.1; their licence files are in `lockly/assets/`. The CVSS 4.0 scoring tables are from FIRST's reference calculator (BSD-2-Clause), credited in `lockly/cvss4_data.py`.
lockly-0.1.0/README.md ADDED
@@ -0,0 +1,150 @@
1
+ [![Lockly: what changed in the lockfile, and why it matters.](https://raw.githubusercontent.com/fullstackspectrum/lockly/main/docs/brand/readme-banner.png)](https://github.com/fullstackspectrum/lockly)
2
+
3
+ [![CI](https://img.shields.io/github/actions/workflow/status/fullstackspectrum/lockly/build.yml?branch=main&style=for-the-badge&logo=githubactions&logoColor=white&label=CI&color=4f8cff&labelColor=10151d)](https://github.com/fullstackspectrum/lockly/actions/workflows/build.yml)
4
+ [![PyPI](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fpypi.org%2Fpypi%2Flockly%2Fjson&query=%24.info.version&prefix=v&label=pypi&style=for-the-badge&logo=pypi&logoColor=white&color=8fb4ff&labelColor=10151d)](https://pypi.org/project/lockly/)
5
+ [![Python](https://img.shields.io/badge/python-3.11%2B-f5c84c?style=for-the-badge&logo=python&logoColor=white&labelColor=10151d)](https://pypi.org/project/lockly/)
6
+ [![License](https://img.shields.io/badge/license-Apache--2.0-646f7f?style=for-the-badge&labelColor=10151d)](https://github.com/fullstackspectrum/lockly/blob/main/LICENSE)
7
+
8
+ # Lockly
9
+
10
+ **What changed in the lockfile, and why it matters.**
11
+
12
+ A dependency bump can change a few lines of `package.json` and thousands of lines of `package-lock.json`. Nobody reviews the second part. Lockly does: it reads the lockfile before and after a change, lists what moved, and flags the changes a reviewer should actually stop for:
13
+
14
+ - **Install scripts:** a package that now runs code when it's installed, the most common route for npm malware.
15
+ - **A new publisher:** a release published by an account new to the package, or no longer through trusted publishing. That's what an account takeover looks like.
16
+ - **Lost provenance:** the release before had a provenance attestation, this one doesn't.
17
+ - **Fresh releases and packages:** a version published in the last few days, or a package that's only weeks old. Most malicious releases are caught and pulled within days.
18
+ - **Changed contents or sources:** the same version with a different hash, or a package suddenly coming from git, a URL or another registry.
19
+ - **Known vulnerabilities** in the new versions, from [OSV](https://osv.dev), and the ones an upgrade fixes.
20
+ - **Deprecations, yanks and licence changes**, including new copyleft terms.
21
+
22
+ It reads **npm, Yarn (classic and Berry), pnpm, uv, Poetry, Pipenv, Go modules and Cargo** lockfiles, and runs on every pull request as a single comment that updates in place.
23
+
24
+ Lockly has no runtime dependencies and needs Python 3.11 or later.
25
+
26
+ > Lockly is a sibling of [Vulnly](https://github.com/fullstackspectrum/Vulnly), [Sbomly](https://github.com/fullstackspectrum/sbomly) and [Basely](https://github.com/fullstackspectrum/basely), and part of [Full-Stack-Spectrum](https://fullstackspectrum.com/): small open-source tools that turn noisy supply chain data into decisions.
27
+
28
+ ![Terminal output from lockly diff](https://raw.githubusercontent.com/fullstackspectrum/lockly/main/docs/screenshots/terminal.png)
29
+
30
+ ## On every pull request
31
+
32
+ ```yaml
33
+ name: Lockfile review
34
+ on: pull_request
35
+
36
+ permissions:
37
+ contents: read
38
+ pull-requests: write # to post the comment
39
+
40
+ jobs:
41
+ lockly:
42
+ runs-on: ubuntu-latest
43
+ steps:
44
+ - uses: actions/checkout@v4
45
+ - uses: fullstackspectrum/lockly@v0
46
+ with:
47
+ fail-on: install-script,publisher,hash
48
+ ```
49
+
50
+ The Action compares the pull request with its base, posts the review as one comment, and edits that comment on every push instead of adding new ones. It also writes the review to the job summary. Pull requests from forks get a read-only token, so there the comment is skipped with a warning and the job summary still has everything.
51
+
52
+ | Input | Default | |
53
+ | --- | --- | --- |
54
+ | `fail-on` | | finding types that fail the check (see below) |
55
+ | `base` | the PR's base commit | git ref to compare against |
56
+ | `paths` | whole repository | space-separated paths to look for lockfiles in |
57
+ | `offline` | `false` | `true` skips registry and OSV lookups |
58
+ | `min-age` | `3` | flag versions published less than this many days ago |
59
+ | `comment` | `true` | post the PR comment |
60
+ | `html`, `markdown`, `json` | `lockly-*` | where to write the reports, e.g. for an artifact upload |
61
+
62
+ ## Install
63
+
64
+ ```bash
65
+ pipx install lockly # or: pip install lockly
66
+ brew install fullstackspectrum/lockly/lockly
67
+ ```
68
+
69
+ There's also a container image for comparing two lockfile files. It has no git, so for `--base` use pip, Homebrew or the Action:
70
+
71
+ ```bash
72
+ docker run --rm -t -v "$PWD:/data" fullstackspectrum/lockly diff old/package-lock.json package-lock.json
73
+ ```
74
+
75
+ ## Usage
76
+
77
+ Compare every lockfile changed on your branch:
78
+
79
+ ```bash
80
+ lockly diff --base origin/main
81
+ ```
82
+
83
+ Lockly compares against the merge base, as a pull request does, so changes that landed on `main` since you branched don't show up. Without `--head` it reads the working tree, including lockfiles you haven't committed yet.
84
+
85
+ Or compare two files:
86
+
87
+ ```bash
88
+ lockly diff old/uv.lock uv.lock
89
+ ```
90
+
91
+ Write reports, and gate CI:
92
+
93
+ ```bash
94
+ lockly diff --base main --markdown comment.md --html report.html --json review.json
95
+ lockly diff --base main --fail-on install-script,publisher,hash
96
+ ```
97
+
98
+ ![Lockly HTML report](https://raw.githubusercontent.com/fullstackspectrum/lockly/main/docs/screenshots/report.png)
99
+
100
+ ## Lockfiles
101
+
102
+ | File | Ecosystem | Notes |
103
+ | --- | --- | --- |
104
+ | `package-lock.json`, `npm-shrinkwrap.json` | npm | lockfile v1 to v3; records licences and install scripts |
105
+ | `yarn.lock` | npm | Yarn classic and Berry; reads `package.json` to tell direct dependencies |
106
+ | `pnpm-lock.yaml` | npm | pnpm 5.4 to 9 (pnpm 10's two-document files too) |
107
+ | `uv.lock` | PyPI | records upload times, so release age needs no lookup |
108
+ | `poetry.lock` | PyPI | reads `pyproject.toml` to tell direct dependencies |
109
+ | `Pipfile.lock` | PyPI | reads `Pipfile` to tell direct dependencies |
110
+ | `go.mod` | Go | Go's lockfile in effect since 1.17; reads `go.sum` for hashes and follows `replace` directives |
111
+ | `Cargo.lock` | crates.io | |
112
+
113
+ ## Findings
114
+
115
+ | Type | Flags | Needs lookups |
116
+ | --- | --- | --- |
117
+ | `hash` | same version, different contents (compared only within one hash algorithm) | |
118
+ | `install-script` | a package that runs a script at install time, new or newly | npm lockfiles record it; other npm formats look it up |
119
+ | `publisher` | a release by an account new to the package, or that left trusted publishing | npm, crates.io |
120
+ | `provenance` | the previous release had a provenance attestation; this one doesn't | npm |
121
+ | `source` | a package from git, a URL, a path or another registry, or a changed source | |
122
+ | `new-package` | an added package first published less than `--new-package-days` (30) ago | yes |
123
+ | `young` | a version published less than `--min-age` (3) days ago | yes, except uv |
124
+ | `vulnerable` | the new version has known vulnerabilities | OSV |
125
+ | `deprecated` | deprecated (npm) or yanked (PyPI, crates.io) | yes |
126
+ | `copyleft` | a licence that brings in copyleft terms | npm lockfiles have licences; others look them up |
127
+ | `license` | a licence changed between copyleft and permissive terms (other changes are shown as info) | as above |
128
+
129
+ Publisher findings compare a release with **the release just before it in the registry**, not with whatever version you were on. A maintainer of the previous release taking a turn isn't flagged; an account new to the package is. Moving to trusted publishing is shown as information, since it's an improvement.
130
+
131
+ `--fail-on` takes any of these, or `any`. Exit codes: `0` passed, `1` a `--fail-on` type was found, `2` bad usage, or a lockfile or git ref that can't be read.
132
+
133
+ ## Network use
134
+
135
+ **By default Lockly looks things up**: the npm registry, PyPI, crates.io, the Go module proxy and OSV, for the packages that changed and nothing else. Responses are cached for a day in `~/.cache/lockly` (or `$LOCKLY_CACHE_DIR`), each request gives up after 5 seconds without a response, and crates.io's limit of one request a second is respected. If a lookup fails, the review still runs and says what it couldn't check.
136
+
137
+ `--offline` (or `LOCKLY_OFFLINE=1`) makes no requests at all: you get the diff, hashes, install scripts and licences the lockfile records, sources, and uv's release dates. The HTML report itself never makes network requests.
138
+
139
+ ## Development
140
+
141
+ ```bash
142
+ uv venv -p 3.14 && uv pip install -e ".[dev]"
143
+ .venv/bin/python -m pytest -q # offline: no test reaches a registry
144
+ .venv/bin/python docs/screenshots/src/render.py # README screenshots (network, Chrome)
145
+ ./docs/brand/src/render.sh # README banner and social preview
146
+ ```
147
+
148
+ ## License
149
+
150
+ Apache-2.0. The embedded Space Grotesk and JetBrains Mono fonts are under the SIL Open Font License 1.1; their licence files are in `lockly/assets/`. The CVSS 4.0 scoring tables are from FIRST's reference calculator (BSD-2-Clause), credited in `lockly/cvss4_data.py`.
@@ -0,0 +1,9 @@
1
+ """Lockly: what changed in a lockfile, and what deserves a closer look."""
2
+
3
+ __version__ = "0.1.0"
4
+
5
+
6
+ def main() -> None:
7
+ from .cli import main as _main
8
+
9
+ _main()
@@ -0,0 +1,3 @@
1
+ from lockly import main
2
+
3
+ main()
@@ -0,0 +1,93 @@
1
+ Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ https://openfontlicense.org
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.