reachdiff 0.9.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.
- reachdiff-0.9.0/LICENSE +202 -0
- reachdiff-0.9.0/PKG-INFO +372 -0
- reachdiff-0.9.0/README.md +349 -0
- reachdiff-0.9.0/pyproject.toml +48 -0
- reachdiff-0.9.0/reachdiff/__init__.py +0 -0
- reachdiff-0.9.0/reachdiff/__main__.py +3 -0
- reachdiff-0.9.0/reachdiff/apply.py +52 -0
- reachdiff-0.9.0/reachdiff/cli.py +88 -0
- reachdiff-0.9.0/reachdiff/collect/__init__.py +0 -0
- reachdiff-0.9.0/reachdiff/collect/live.py +463 -0
- reachdiff-0.9.0/reachdiff/collect/offline.py +32 -0
- reachdiff-0.9.0/reachdiff/config.py +135 -0
- reachdiff-0.9.0/reachdiff/diff.py +234 -0
- reachdiff-0.9.0/reachdiff/report.py +215 -0
- reachdiff-0.9.0/reachdiff/resolve.py +104 -0
- reachdiff-0.9.0/reachdiff/rules.py +197 -0
- reachdiff-0.9.0/reachdiff/scope.py +21 -0
- reachdiff-0.9.0/reachdiff/state.py +89 -0
- reachdiff-0.9.0/reachdiff/tfplan.py +352 -0
- reachdiff-0.9.0/reachdiff.egg-info/PKG-INFO +372 -0
- reachdiff-0.9.0/reachdiff.egg-info/SOURCES.txt +37 -0
- reachdiff-0.9.0/reachdiff.egg-info/dependency_links.txt +1 -0
- reachdiff-0.9.0/reachdiff.egg-info/entry_points.txt +2 -0
- reachdiff-0.9.0/reachdiff.egg-info/requires.txt +3 -0
- reachdiff-0.9.0/reachdiff.egg-info/top_level.txt +1 -0
- reachdiff-0.9.0/setup.cfg +4 -0
- reachdiff-0.9.0/tests/test_apply.py +72 -0
- reachdiff-0.9.0/tests/test_cli.py +180 -0
- reachdiff-0.9.0/tests/test_diff.py +204 -0
- reachdiff-0.9.0/tests/test_live.py +377 -0
- reachdiff-0.9.0/tests/test_offline.py +57 -0
- reachdiff-0.9.0/tests/test_publish.py +244 -0
- reachdiff-0.9.0/tests/test_report.py +201 -0
- reachdiff-0.9.0/tests/test_resolve.py +60 -0
- reachdiff-0.9.0/tests/test_rules.py +260 -0
- reachdiff-0.9.0/tests/test_sanitize.py +99 -0
- reachdiff-0.9.0/tests/test_scenarios.py +86 -0
- reachdiff-0.9.0/tests/test_state.py +34 -0
- reachdiff-0.9.0/tests/test_tfplan.py +251 -0
reachdiff-0.9.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
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.
|
|
202
|
+
|
reachdiff-0.9.0/PKG-INFO
ADDED
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: reachdiff
|
|
3
|
+
Version: 0.9.0
|
|
4
|
+
Summary: Effective Unity Catalog access diff for Terraform plans
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://github.com/reachdiff/reachdiff
|
|
7
|
+
Project-URL: Issues, https://github.com/reachdiff/reachdiff/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/reachdiff/reachdiff/blob/main/CHANGELOG.md
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Classifier: Topic :: Security
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Provides-Extra: databricks
|
|
21
|
+
Requires-Dist: databricks-sdk==0.140.0; extra == "databricks"
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# reachdiff
|
|
25
|
+
|
|
26
|
+
**Who gains or loses access to what when this Terraform plan is applied?**
|
|
27
|
+
|
|
28
|
+
reachdiff reads `terraform show -json` output for Databricks Unity Catalog grants
|
|
29
|
+
(`databricks_grants`, `databricks_grant`), group memberships (`databricks_group_member`)
|
|
30
|
+
and owners. It reports the **effective-access diff**, with the route behind each change, and
|
|
31
|
+
returns an exit code a pipeline can act on.
|
|
32
|
+
|
|
33
|
+
Status: beta. Live mode has been exercised against one Azure Databricks workspace; see
|
|
34
|
+
[Validated scope](#validated-scope) for what that covers and what it doesn't. The demo and tests use synthetic plans.
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
|
|
38
|
+
Python 3.11 or newer:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install reachdiff # offline mode, no dependencies
|
|
42
|
+
pip install 'reachdiff[databricks]' # live mode, adds databricks-sdk
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Try the synthetic demo
|
|
46
|
+
|
|
47
|
+
Python 3.11 or newer, no dependencies:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
python3 -m reachdiff plan --tfplan examples/schema-grant.plan.json --offline
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
It reports `analysts` gaining READ on all of `prod.sales` (3 members: 2 new, 1 already had it)
|
|
54
|
+
and `bob@example.com` losing WRITE on `prod.sales.orders`. Offline runs report what they couldn't
|
|
55
|
+
see, so the status is WARN.
|
|
56
|
+
|
|
57
|
+

|
|
58
|
+
|
|
59
|
+
The recording is made with [vhs](https://github.com/charmbracelet/vhs) from [`docs/demo/offline.tape`](docs/demo/offline.tape).
|
|
60
|
+
|
|
61
|
+
## Use it on a plan
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
terraform plan -out plan.bin
|
|
65
|
+
terraform show -json plan.bin > local/plan.json # real plans can contain secrets: keep them out of Git
|
|
66
|
+
python3 -m venv .venv && .venv/bin/pip install -e '.[databricks]'
|
|
67
|
+
.venv/bin/reachdiff plan --tfplan local/plan.json --profile PROFILE --format md --output local/report.md
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
| Option | Meaning |
|
|
71
|
+
|---|---|
|
|
72
|
+
| `--offline` | Use only data in the plan. Anything Terraform doesn't manage is reported as a gap. |
|
|
73
|
+
| `--profile NAME` | Databricks SDK profile for live mode. Live mode only reads, and only the objects and groups the plan touches. Without a profile, live mode logs in from the SDK's environment variables and needs `DATABRICKS_AUTH_TYPE` (see [CI](#ci)). |
|
|
74
|
+
| `--deep` | Also read the child tables of changed schemas and catalogs. Live mode only: `--offline --deep` is a usage error (exit 3). |
|
|
75
|
+
| `--config FILE` | TOML rules (see below). |
|
|
76
|
+
| `--format text\|json\|md` | `md` is meant for PR comments. |
|
|
77
|
+
| `--fail-on block\|warn\|never` | Default `block`. |
|
|
78
|
+
|
|
79
|
+
Exit codes: `0` below the fail threshold, `1` WARN, `2` BLOCK, `3` invalid input, config or
|
|
80
|
+
authentication error, or any other operational failure. A live run in which no Databricks read
|
|
81
|
+
succeeds (a total outage) is exit 3, not a report full of gaps.
|
|
82
|
+
|
|
83
|
+
## Live mode setup
|
|
84
|
+
|
|
85
|
+
Live mode runs as a dedicated identity, usually a service principal in CI. It needs:
|
|
86
|
+
|
|
87
|
+
- **Workspace access:** assigned to the workspace with an entitlement. New workspaces give the `users` group none, and
|
|
88
|
+
without one every API reachdiff calls is refused. `workspace-consume` is the least of the three the API accepts.
|
|
89
|
+
- **`READ METADATA`** on the metastore (it inherits to every object) or on each catalog in scope, so the permissions
|
|
90
|
+
API returns every grant, not only the caller's own. Without it, reachdiff discards the list and reports
|
|
91
|
+
`unreadable_object`, so the run cannot pass. `MANAGE` and ownership also work, but `MANAGE` lets the scanner grant
|
|
92
|
+
itself data access.
|
|
93
|
+
- **An OAuth secret.** For a secret limited to API scopes (`unity-catalog`, `scim`, `access-management`), set the same
|
|
94
|
+
`scopes` in the profile; the SDK otherwise requests `all-apis` and is refused. Set `auth_type = oauth-m2m`: without
|
|
95
|
+
it the Databricks CLI silently falls back to other credentials, such as an `az login` session.
|
|
96
|
+
- **Group membership** comes from workspace SCIM, which shows members only to workspace admins. Without admin,
|
|
97
|
+
reachdiff reports one `membership_incomplete` gap and "members not read", and runs that touch groups stay
|
|
98
|
+
unverified. Making the scanner a workspace admin gives complete member counts but lets it change workspace settings
|
|
99
|
+
and identities.
|
|
100
|
+
|
|
101
|
+
On Azure, the account console rejects personal Microsoft accounts: use a member user of your Entra ID directory.
|
|
102
|
+
`az login --allow-no-subscriptions` is enough for a user without an Azure subscription role.
|
|
103
|
+
|
|
104
|
+
## CI
|
|
105
|
+
|
|
106
|
+
Run reachdiff in the job that ran `terraform plan`, on the plan JSON in the runner's temporary directory. Never upload
|
|
107
|
+
the plan JSON as an artifact: it shows sensitive values in plain text.
|
|
108
|
+
|
|
109
|
+
The GitHub Action (`action.yml`) and the Azure DevOps template (`ci/azure-pipelines/reachdiff.yml`) install reachdiff
|
|
110
|
+
from their own checkout, run it, write the report to the run summary and, if asked, post one pull-request comment that
|
|
111
|
+
later runs update. reachdiff itself never posts. `ci/publish.py` does, and only:
|
|
112
|
+
|
|
113
|
+
- in private repositories and projects. Anywhere else, including GitHub `internal` repositories or when the
|
|
114
|
+
visibility can't be read, the log gets only the status line, unless `allow-public` is set.
|
|
115
|
+
- on pull requests. On GitHub it never posts for a `pull_request_target` run from a fork.
|
|
116
|
+
|
|
117
|
+
An error replaces the comment with "reachdiff: ERROR", and a failed post fails the step with exit 3, so a comment never
|
|
118
|
+
shows an earlier, better status. A report too long for a comment (65,536 characters on GitHub, 150,000 on Azure
|
|
119
|
+
DevOps) is replaced by its status and a pointer to the run summary.
|
|
120
|
+
|
|
121
|
+
| Status | Exit code (default `fail_on = block`) | GitHub | Azure DevOps |
|
|
122
|
+
|---|---|---|---|
|
|
123
|
+
| PASS | 0 | success | succeeded |
|
|
124
|
+
| WARN below the threshold | 0 | success with a warning | succeeded with issues |
|
|
125
|
+
| WARN at the threshold, or BLOCK | 1 or 2 | failed | failed |
|
|
126
|
+
| ERROR | 3 | failed | failed |
|
|
127
|
+
|
|
128
|
+
**Login.** Without `--profile`, live mode logs in from the SDK's environment variables. Set them on the reachdiff step
|
|
129
|
+
only: `DATABRICKS_HOST`, `DATABRICKS_CLIENT_ID` and always `DATABRICKS_AUTH_TYPE`. reachdiff refuses live mode without
|
|
130
|
+
a profile or `DATABRICKS_AUTH_TYPE` (exit 3): the SDK would otherwise try every login it finds, such as the Terraform
|
|
131
|
+
deployer's `ARM_*` secrets or an `az login` session, and run with more visibility than the scanner has.
|
|
132
|
+
|
|
133
|
+
To store no secret in CI, use token federation (`github-oidc` or `azure-devops-oidc`) with a federation policy on the
|
|
134
|
+
scanning service principal. An account admin creates it in the account console or with the Terraform resource
|
|
135
|
+
`databricks_service_principal_federation_policy`:
|
|
136
|
+
|
|
137
|
+
| Platform | Issuer | Subject | Audience |
|
|
138
|
+
|---|---|---|---|
|
|
139
|
+
| GitHub Actions | `https://token.actions.githubusercontent.com` | `<prefix>:pull_request` | `https://<workspace host>/oidc/v1/token` |
|
|
140
|
+
| Azure DevOps | `https://vstoken.dev.azure.com/<organization ID>` | `p://ORGANIZATION/PROJECT/PIPELINE` | `api://AzureADTokenExchange` |
|
|
141
|
+
|
|
142
|
+
On GitHub, `<prefix>` is `sub_claim_prefix` from `gh api repos/OWNER/REPO/actions/oidc/customization/sub`. With
|
|
143
|
+
GitHub's immutable subject it includes the IDs, for example `repo:OWNER@OWNER_ID/REPO@REPO_ID`. The audience is the
|
|
144
|
+
one the workspace advertises (`token_federation_default_oidc_audiences` in
|
|
145
|
+
`https://<workspace host>/.well-known/databricks-config`), which the SDK requests. To use another audience, set the
|
|
146
|
+
same value in the policy and in `DATABRICKS_TOKEN_AUDIENCE`.
|
|
147
|
+
|
|
148
|
+
The scanning identity needs the privileges in [Live mode setup](#live-mode-setup). With a scoped OAuth secret
|
|
149
|
+
(`oauth-m2m`) instead: the SDK has no environment variable for `scopes`. Point `DATABRICKS_CONFIG_FILE` at a file that
|
|
150
|
+
holds only a profile with `scopes` and `auth_type = oauth-m2m`, set `DATABRICKS_CONFIG_PROFILE` to that profile, and
|
|
151
|
+
keep the secret in `DATABRICKS_CLIENT_SECRET`.
|
|
152
|
+
|
|
153
|
+
**If the login fails,** reachdiff exits 3 with "Databricks login failed" and the settings to check. It never prints
|
|
154
|
+
the SDK's message, which can name the host, the client ID and the token subject. To see it, add a temporary step
|
|
155
|
+
before reachdiff with the same `env:` (GitHub shown), in a private repository only, and remove it afterwards:
|
|
156
|
+
|
|
157
|
+
```yaml
|
|
158
|
+
- name: debug login (temporary)
|
|
159
|
+
env: # the same DATABRICKS_* values as the reachdiff step
|
|
160
|
+
DATABRICKS_HOST: ${{ vars.DATABRICKS_HOST }}
|
|
161
|
+
DATABRICKS_CLIENT_ID: ${{ vars.SCANNER_CLIENT_ID }}
|
|
162
|
+
DATABRICKS_AUTH_TYPE: github-oidc
|
|
163
|
+
run: |
|
|
164
|
+
python3 -m venv "$RUNNER_TEMP/dbg" && "$RUNNER_TEMP/dbg/bin/pip" install --quiet databricks-sdk==0.140.0
|
|
165
|
+
"$RUNNER_TEMP/dbg/bin/python" - <<'EOF'
|
|
166
|
+
import base64, json, os, urllib.parse, urllib.request
|
|
167
|
+
host = os.environ['DATABRICKS_HOST'].rstrip('/')
|
|
168
|
+
audience = json.load(urllib.request.urlopen(host + '/.well-known/databricks-config'))['token_federation_default_oidc_audiences'][0]
|
|
169
|
+
url = os.environ['ACTIONS_ID_TOKEN_REQUEST_URL'] + '&audience=' + urllib.parse.quote(audience, safe='')
|
|
170
|
+
request = urllib.request.Request(url, headers={'Authorization': 'Bearer ' + os.environ['ACTIONS_ID_TOKEN_REQUEST_TOKEN']})
|
|
171
|
+
claims = json.loads(base64.urlsafe_b64decode(json.load(urllib.request.urlopen(request))['value'].split('.')[1] + '=='))
|
|
172
|
+
print({k: claims.get(k) for k in ('iss', 'sub', 'aud')}, 'aud is the advertised audience:', claims.get('aud') == audience)
|
|
173
|
+
from databricks.sdk import WorkspaceClient
|
|
174
|
+
try:
|
|
175
|
+
print('logged in:', WorkspaceClient().current_user.me().active)
|
|
176
|
+
except Exception as exc:
|
|
177
|
+
print(type(exc).__name__, exc)
|
|
178
|
+
EOF
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### GitHub Actions
|
|
182
|
+
|
|
183
|
+
```yaml
|
|
184
|
+
permissions:
|
|
185
|
+
contents: read
|
|
186
|
+
pull-requests: write # the comment
|
|
187
|
+
id-token: write # github-oidc
|
|
188
|
+
steps:
|
|
189
|
+
# ... terraform plan -out "$RUNNER_TEMP/plan.bin" and show -json into "$RUNNER_TEMP/plan.json"
|
|
190
|
+
- uses: reachdiff/reachdiff@FULL_COMMIT_SHA
|
|
191
|
+
with:
|
|
192
|
+
plan-json: ${{ runner.temp }}/plan.json
|
|
193
|
+
comment: true
|
|
194
|
+
env:
|
|
195
|
+
DATABRICKS_HOST: ${{ vars.DATABRICKS_HOST }}
|
|
196
|
+
DATABRICKS_CLIENT_ID: ${{ vars.SCANNER_CLIENT_ID }}
|
|
197
|
+
DATABRICKS_AUTH_TYPE: github-oidc
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
| Input | Default | Meaning |
|
|
201
|
+
|---|---|---|
|
|
202
|
+
| `plan-json` | required | Path to the `terraform show -json` output |
|
|
203
|
+
| `mode` | `live` | `live` or `offline` |
|
|
204
|
+
| `deep`, `config`, `fail-on` | off | As the CLI options |
|
|
205
|
+
| `comment` | `false` | Post or update the pull-request comment |
|
|
206
|
+
| `allow-public` | `false` | Write the summary and comment even if the repository is not private |
|
|
207
|
+
| `comment-key` | `default` | Keeps separate comments for several plans in one pull request |
|
|
208
|
+
| `github-token` | `github.token` | Used only for the comment |
|
|
209
|
+
|
|
210
|
+
Outputs: `status` (`PASS`, `WARN`, `BLOCK` or `ERROR`), `exit-code` and `report-path`. Pin the action to a full commit
|
|
211
|
+
SHA. While this repository is private, only repositories with the same owner can use it (Settings → Actions →
|
|
212
|
+
General → Access). Pull requests from forks get no secrets and no OIDC token, so live mode stops there with exit 3. A
|
|
213
|
+
full workflow is in [`examples/ci/github-workflow.yml`](examples/ci/github-workflow.yml).
|
|
214
|
+
|
|
215
|
+
### Azure DevOps
|
|
216
|
+
|
|
217
|
+
Check out this repository as a repository resource next to your own, with explicit paths (a second checkout otherwise
|
|
218
|
+
moves yours to `s/<repo name>`), then include the template after `terraform show -json`:
|
|
219
|
+
|
|
220
|
+
```yaml
|
|
221
|
+
resources:
|
|
222
|
+
repositories:
|
|
223
|
+
- repository: reachdiff
|
|
224
|
+
type: github
|
|
225
|
+
endpoint: GITHUB_CONNECTION
|
|
226
|
+
name: reachdiff/reachdiff
|
|
227
|
+
ref: FULL_COMMIT_SHA
|
|
228
|
+
steps:
|
|
229
|
+
- checkout: self
|
|
230
|
+
path: self
|
|
231
|
+
- checkout: reachdiff
|
|
232
|
+
path: reachdiff
|
|
233
|
+
# ... terraform plan and show -json into $(Agent.TempDirectory)/plan.json
|
|
234
|
+
- template: ci/azure-pipelines/reachdiff.yml@reachdiff
|
|
235
|
+
parameters:
|
|
236
|
+
planJson: $(Agent.TempDirectory)/plan.json
|
|
237
|
+
reachdiffPath: $(Pipeline.Workspace)/reachdiff
|
|
238
|
+
host: $(DATABRICKS_HOST)
|
|
239
|
+
clientId: $(SCANNER_CLIENT_ID)
|
|
240
|
+
comment: true
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
The parameters match the action's inputs (`planJson`, `mode`, `deep`, `config`, `failOn`, `comment`, `allowPublic`,
|
|
244
|
+
`commentKey`), plus `python` (default `python3`, 3.11 or newer) and the login: `host`, `clientId` and `authType`
|
|
245
|
+
(default `azure-devops-oidc`). They are set on the reachdiff step only, so they never change how your Terraform steps
|
|
246
|
+
log in. Use the template once per job. Outputs: `reachdiff.status`, `reachdiff.exitCode`, `reachdiff.reportPath`.
|
|
247
|
+
|
|
248
|
+
The project's build service needs **Contribute to pull requests** on the repository (Project settings →
|
|
249
|
+
Repositories → Security). Pull requests run the pipeline through a build validation branch policy. A full pipeline is
|
|
250
|
+
in [`examples/ci/azure-pipelines.yml`](examples/ci/azure-pipelines.yml).
|
|
251
|
+
|
|
252
|
+
## Validated scope
|
|
253
|
+
|
|
254
|
+
Live mode was exercised from 1 to 3 October 2026 against one Azure Databricks trial workspace (Premium, classic compute)
|
|
255
|
+
with Terraform 1.16.4, provider `databricks/databricks` 1.135.0, Databricks CLI 1.19.0, databricks-sdk 0.140.0 and
|
|
256
|
+
Python 3.14. The objects, groups and grants were synthetic. The scenarios and predictions are in
|
|
257
|
+
[`validation/azure/`](validation/azure/); real plans and results stay outside the repository. These runs used the code
|
|
258
|
+
before its rename to reachdiff on 3 October 2026 (see [CHANGELOG.md](CHANGELOG.md)). From 4 to 6 October 2026 the
|
|
259
|
+
renamed code ran against the same workspace again, as the GitHub Action, the Azure DevOps template and the CLI, and
|
|
260
|
+
produced the predicted WARN and BLOCK reports.
|
|
261
|
+
|
|
262
|
+
Covered:
|
|
263
|
+
|
|
264
|
+
- Plan reading for `databricks_grants`, `databricks_grant`, `databricks_group_member` and owners on catalogs, schemas
|
|
265
|
+
and tables, including replaced resources, values known only after apply and a literal provider host.
|
|
266
|
+
- Runs as the workspace's admin user and as a service principal with `workspace-consume` at four privilege levels on
|
|
267
|
+
the catalog: none, `BROWSE`, `READ METADATA`, and `READ METADATA` with `BROWSE`, `USE CATALOG` and `USE SCHEMA`.
|
|
268
|
+
`READ METADATA` on the catalog alone gave complete grant, owner and tag reads. Below it, every grant list was
|
|
269
|
+
discarded and no run passed.
|
|
270
|
+
- The visibility self-check against real SCIM `Me` and effective-permissions responses.
|
|
271
|
+
- Ownership: a service principal that owned a table without a `SELECT` grant could read it, and was refused `SELECT`
|
|
272
|
+
on a table it did not own.
|
|
273
|
+
- A plan that only changes the case of a schema name reports no change.
|
|
274
|
+
- Group membership read without workspace admin: one `membership_incomplete` gap, "members not read".
|
|
275
|
+
- Paginated listings with `--deep`, tags on tables and columns, and the SDK errors `Unauthenticated`,
|
|
276
|
+
`PermissionDenied` and `NotFound`.
|
|
277
|
+
- CI, on 2 and 3 October 2026: the GitHub Action on a GitHub-hosted Ubuntu runner (Python 3.11) and the Azure DevOps
|
|
278
|
+
template on a self-hosted macOS agent (Python 3.14). reachdiff logged in as the scanning service principal by token
|
|
279
|
+
federation (`github-oidc`, `azure-devops-oidc`) with the policy settings under [CI](#ci); no fallback login was
|
|
280
|
+
needed. The pull request comment (a thread on Azure DevOps) was created once, then updated in place, and the job
|
|
281
|
+
results matched WARN, BLOCK and ERROR. With a wrong client ID for reachdiff only, the run ended in ERROR without
|
|
282
|
+
falling back to another login, also on the self-hosted agent, where a CLI profile and an Azure CLI login existed.
|
|
283
|
+
- Data classification, on 3 October 2026: with automatic tagging on for the class, it tagged an email column
|
|
284
|
+
`class.email_address`, which the default `[sensitive].tags` pattern `class.*` matches. Without automatic tagging,
|
|
285
|
+
classification only reports its detections and writes no tags.
|
|
286
|
+
|
|
287
|
+
Not covered:
|
|
288
|
+
|
|
289
|
+
- AWS and GCP, serverless workspaces, and more than one workspace or metastore.
|
|
290
|
+
- `READ METADATA` granted on the metastore rather than the catalog; visibility through `MANAGE`, ownership or
|
|
291
|
+
metastore admin (unit tests only); a scanner that is workspace admin.
|
|
292
|
+
- Terraform's own token federation login in CI: the sample plan only created resources, so `terraform plan` made no
|
|
293
|
+
Databricks request.
|
|
294
|
+
- Microsoft-hosted Azure DevOps agents, GitHub pull requests from forks, and public repositories or projects (the
|
|
295
|
+
refusal is covered by unit tests only).
|
|
296
|
+
- Everything under [Not evaluated](#not-evaluated), including runtime behavior such as the gap between destroying and
|
|
297
|
+
recreating a replaced `databricks_grants` resource.
|
|
298
|
+
|
|
299
|
+
## Rules
|
|
300
|
+
|
|
301
|
+
Built-in rules default to WARN: `broad_principal`, `broad_privilege`, `individual_owner`, `sensitive_access` and
|
|
302
|
+
`unverified`. `grant_resource_conflict` defaults to BLOCK: it fires when a plan changes access and more than one
|
|
303
|
+
resource sets the grants on one securable (`conflicting_grant_resources` below). The applied result then depends on
|
|
304
|
+
apply order, and grants can be lost without an error: in the live session, moving grants from `databricks_grants` to
|
|
305
|
+
`databricks_grant` removed every grant on a table. `unverified` reports what reachdiff couldn't see. It can be raised
|
|
306
|
+
to BLOCK but never turned off. Among the gaps it reports:
|
|
307
|
+
|
|
308
|
+
- `latent_grants` and `deactivated_grants`: a usage privilege (`USE_CATALOG`, `USE_SCHEMA`,
|
|
309
|
+
`ALL_PRIVILEGES`) is granted or revoked on a catalog or schema, so grants below it may start or
|
|
310
|
+
stop working. Without `--deep` they are not enumerated. With `--deep` they appear as gains and
|
|
311
|
+
losses.
|
|
312
|
+
- `conflicting_grant_resources`: more than one resource sets the grants on one securable
|
|
313
|
+
(`databricks_grants` with `databricks_grant`, two `databricks_grants`, or two `databricks_grant` for the same
|
|
314
|
+
principal), so the applied result depends on apply order.
|
|
315
|
+
- `sensitivity_not_evaluated`: a schema- or catalog-level gain without `--deep`, or, with `--deep`,
|
|
316
|
+
a gain over tables the plan doesn't change. Column tags are read only for changed tables, so child
|
|
317
|
+
column tags are reported as a gap.
|
|
318
|
+
|
|
319
|
+
```toml
|
|
320
|
+
fail_on = "block"
|
|
321
|
+
|
|
322
|
+
[sensitive]
|
|
323
|
+
tags = ["pii*", "sensitive*", "class.*"]
|
|
324
|
+
|
|
325
|
+
[[rule]]
|
|
326
|
+
id = "pii-only-approved-groups"
|
|
327
|
+
severity = "BLOCK"
|
|
328
|
+
sensitive = true
|
|
329
|
+
unless_via = ["pii-readers"]
|
|
330
|
+
message = "New access to PII outside approved groups"
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
Configured rules fail closed. They match every row before child rows collapse into parent rows. An
|
|
334
|
+
`objects` glob also matches rows on a parent of the objects it names (`prod.*` matches a
|
|
335
|
+
catalog-level row on `prod`). `principal_kinds` also matches principals whose kind is unknown.
|
|
336
|
+
|
|
337
|
+
## Handle reports with care
|
|
338
|
+
|
|
339
|
+
Reports contain principal and object names. Don't post them as comments in public repositories.
|
|
340
|
+
reachdiff never posts anywhere itself; the CI publish script withholds reports outside private repositories (see
|
|
341
|
+
[CI](#ci)).
|
|
342
|
+
|
|
343
|
+
## Not evaluated
|
|
344
|
+
|
|
345
|
+
- ABAC policies, row filters and column masks
|
|
346
|
+
- volumes, functions and external locations
|
|
347
|
+
- workspace-level ACLs
|
|
348
|
+
- metastore and workspace admin powers
|
|
349
|
+
- identity-provider membership completeness
|
|
350
|
+
- runtime behavior
|
|
351
|
+
|
|
352
|
+
## Development
|
|
353
|
+
|
|
354
|
+
```bash
|
|
355
|
+
python3 -m unittest discover -v
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
`pre-commit install` adds hooks that run ruff (`ruff check`, `ruff format`) and gitleaks on every commit; gitleaks must
|
|
359
|
+
be on your PATH (for example `brew install gitleaks`). CI runs the tests on Python 3.11 and 3.14, the same ruff checks
|
|
360
|
+
and a gitleaks scan of the history. Fake values that look like secrets go into `.gitleaks.toml`, with their source.
|
|
361
|
+
|
|
362
|
+
Tests also run on sanitized plans and API responses from the live sessions (`tests/fixtures/real/`). To refresh them
|
|
363
|
+
from the ignored `local/validation/`, run `python3 -m validation.sanitize`; it copies only what reachdiff reads,
|
|
364
|
+
replaces identifiers with placeholders and refuses to write output that still looks like it holds one. Read each
|
|
365
|
+
fixture diff before committing.
|
|
366
|
+
|
|
367
|
+
## Licence and trademarks
|
|
368
|
+
|
|
369
|
+
Apache License 2.0, see [LICENSE](LICENSE).
|
|
370
|
+
|
|
371
|
+
reachdiff is an independent project, not affiliated with or endorsed by Databricks or HashiCorp. Databricks, Unity
|
|
372
|
+
Catalog and Terraform are trademarks of their owners.
|