datasecops-cli 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 (37) hide show
  1. datasecops_cli-0.1.0/.github/workflows/publish-cli.yml +56 -0
  2. datasecops_cli-0.1.0/.gitignore +222 -0
  3. datasecops_cli-0.1.0/LICENSE +21 -0
  4. datasecops_cli-0.1.0/PKG-INFO +16 -0
  5. datasecops_cli-0.1.0/README.md +191 -0
  6. datasecops_cli-0.1.0/docs/legacy.md +23 -0
  7. datasecops_cli-0.1.0/docs/legacy_plan_of_action.md +402 -0
  8. datasecops_cli-0.1.0/pyproject.toml +27 -0
  9. datasecops_cli-0.1.0/setup.ps1 +98 -0
  10. datasecops_cli-0.1.0/setup.sh +97 -0
  11. datasecops_cli-0.1.0/src/datasecops_cli/__init__.py +1 -0
  12. datasecops_cli-0.1.0/src/datasecops_cli/config.py +100 -0
  13. datasecops_cli-0.1.0/src/datasecops_cli/main.py +122 -0
  14. datasecops_cli-0.1.0/src/datasecops_cli/menus/__init__.py +1 -0
  15. datasecops_cli-0.1.0/src/datasecops_cli/menus/development.py +160 -0
  16. datasecops_cli-0.1.0/src/datasecops_cli/menus/downloads.py +79 -0
  17. datasecops_cli-0.1.0/src/datasecops_cli/menus/git_operations.py +213 -0
  18. datasecops_cli-0.1.0/src/datasecops_cli/models/__init__.py +1 -0
  19. datasecops_cli-0.1.0/src/datasecops_cli/models/git_helpers.py +29 -0
  20. datasecops_cli-0.1.0/src/datasecops_cli/models/project_config.py +87 -0
  21. datasecops_cli-0.1.0/src/datasecops_cli/services/__init__.py +1 -0
  22. datasecops_cli-0.1.0/src/datasecops_cli/services/dbt_runner.py +130 -0
  23. datasecops_cli-0.1.0/src/datasecops_cli/services/download_service.py +103 -0
  24. datasecops_cli-0.1.0/src/datasecops_cli/services/git_service.py +183 -0
  25. datasecops_cli-0.1.0/src/datasecops_cli/services/linting_service.py +47 -0
  26. datasecops_cli-0.1.0/src/datasecops_cli/services/skill_service.py +86 -0
  27. datasecops_cli-0.1.0/src/datasecops_cli/services/snowflake_service.py +62 -0
  28. datasecops_cli-0.1.0/src/datasecops_cli/utilities/__init__.py +1 -0
  29. datasecops_cli-0.1.0/src/datasecops_cli/utilities/display.py +122 -0
  30. datasecops_cli-0.1.0/src/datasecops_cli/utilities/file_utils.py +33 -0
  31. datasecops_cli-0.1.0/src/datasecops_cli/utilities/yaml_utils.py +39 -0
  32. datasecops_cli-0.1.0/tests/__init__.py +1 -0
  33. datasecops_cli-0.1.0/tests/test_config.py +87 -0
  34. datasecops_cli-0.1.0/tests/test_file_utils.py +92 -0
  35. datasecops_cli-0.1.0/tests/test_models.py +155 -0
  36. datasecops_cli-0.1.0/tests/test_version.py +29 -0
  37. datasecops_cli-0.1.0/tests/test_yaml_utils.py +93 -0
@@ -0,0 +1,56 @@
1
+ name: Publish datasecops-cli to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'cli-v*'
7
+
8
+ permissions:
9
+ id-token: write
10
+ contents: read
11
+
12
+ jobs:
13
+ test:
14
+ name: Test (Python ${{ matrix.python-version }})
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ matrix:
18
+ python-version: ['3.11', '3.12', '3.13']
19
+
20
+ steps:
21
+ - name: Checkout repository
22
+ uses: actions/checkout@v4
23
+
24
+ - name: Set up Python ${{ matrix.python-version }}
25
+ uses: actions/setup-python@v5
26
+ with:
27
+ python-version: ${{ matrix.python-version }}
28
+
29
+ - name: Install package with test dependencies
30
+ run: pip install -e ".[test]"
31
+
32
+ - name: Run tests
33
+ run: pytest --tb=short
34
+
35
+ build-and-publish:
36
+ name: Build and publish to PyPI
37
+ needs: test
38
+ runs-on: ubuntu-latest
39
+
40
+ steps:
41
+ - name: Checkout repository
42
+ uses: actions/checkout@v4
43
+
44
+ - name: Set up Python
45
+ uses: actions/setup-python@v5
46
+ with:
47
+ python-version: '3.11'
48
+
49
+ - name: Install build tools
50
+ run: pip install build
51
+
52
+ - name: Build package
53
+ run: python -m build
54
+
55
+ - name: Publish to PyPI
56
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,222 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ # Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ # poetry.lock
109
+ # poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ # pdm.lock
116
+ # pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ # pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # Redis
135
+ *.rdb
136
+ *.aof
137
+ *.pid
138
+
139
+ # RabbitMQ
140
+ mnesia/
141
+ rabbitmq/
142
+ rabbitmq-data/
143
+
144
+ # ActiveMQ
145
+ activemq-data/
146
+
147
+ # SageMath parsed files
148
+ *.sage.py
149
+
150
+ # Environments
151
+ .env
152
+ .envrc
153
+ .venv
154
+ env/
155
+ venv/
156
+ ENV/
157
+ env.bak/
158
+ venv.bak/
159
+
160
+ # Spyder project settings
161
+ .spyderproject
162
+ .spyproject
163
+
164
+ # Rope project settings
165
+ .ropeproject
166
+
167
+ # mkdocs documentation
168
+ /site
169
+
170
+ # mypy
171
+ .mypy_cache/
172
+ .dmypy.json
173
+ dmypy.json
174
+
175
+ # Pyre type checker
176
+ .pyre/
177
+
178
+ # pytype static type analyzer
179
+ .pytype/
180
+
181
+ # Cython debug symbols
182
+ cython_debug/
183
+
184
+ # PyCharm
185
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
186
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
187
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
188
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
189
+ # .idea/
190
+
191
+ # Abstra
192
+ # Abstra is an AI-powered process automation framework.
193
+ # Ignore directories containing user credentials, local state, and settings.
194
+ # Learn more at https://abstra.io/docs
195
+ .abstra/
196
+
197
+ # Visual Studio Code
198
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
199
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
200
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
201
+ # you could uncomment the following to ignore the entire vscode folder
202
+ # .vscode/
203
+ # Temporary file for partial code execution
204
+ tempCodeRunnerFile.py
205
+
206
+ # Ruff stuff:
207
+ .ruff_cache/
208
+
209
+ # PyPI configuration file
210
+ .pypirc
211
+
212
+ # Marimo
213
+ marimo/_static/
214
+ marimo/_lsp/
215
+ __marimo__/
216
+
217
+ # Streamlit
218
+ .streamlit/secrets.toml
219
+
220
+
221
+ legacy_framework/
222
+ plans/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Data Engineers
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,16 @@
1
+ Metadata-Version: 2.4
2
+ Name: datasecops-cli
3
+ Version: 0.1.0
4
+ Summary: DataSecOps Framework CLI for Snowflake Native App
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.10
8
+ Requires-Dist: colorama>=0.4
9
+ Requires-Dist: gitpython>=3.1
10
+ Requires-Dist: pydantic>=2.0
11
+ Requires-Dist: pyyaml>=6.0
12
+ Requires-Dist: snowflake-connector-python>=3.0
13
+ Requires-Dist: sqlfluff>=3.0
14
+ Provides-Extra: test
15
+ Requires-Dist: pytest-cov>=4.0; extra == 'test'
16
+ Requires-Dist: pytest>=7.0; extra == 'test'
@@ -0,0 +1,191 @@
1
+ # DataSecOps Framework CLI
2
+
3
+ Command-line interface for the DataSecOps Framework Snowflake Native App. Provides interactive menus for dbt development, git source control, and downloading framework configurations locally.
4
+
5
+ ## Prerequisites
6
+
7
+ Before running setup, ensure you have:
8
+
9
+ 1. **Python 3.10+** installed
10
+ 2. **A Snowflake connection** configured in `~/.snowflake/connections.toml`
11
+ 3. **The DataSecOps Framework native app** installed in your Snowflake account
12
+ 4. **A project profile** created in the native app (via the admin UI)
13
+
14
+ Optional but recommended:
15
+
16
+ - **dbt Fusion** (or dbt-core with dbt-snowflake) — required for dbt commands
17
+ - **Cortex Code** — required for skill downloads
18
+
19
+ ## Quick Start
20
+
21
+ ### 1. Run the setup script
22
+
23
+ The setup script checks prerequisites, creates a virtual environment, installs the CLI, and writes your local configuration.
24
+
25
+ **Linux / macOS:**
26
+
27
+ ```bash
28
+ chmod +x setup.sh
29
+ ./setup.sh
30
+ ```
31
+
32
+ **Windows (PowerShell):**
33
+
34
+ ```powershell
35
+ .\setup.ps1
36
+ ```
37
+
38
+ The script will prompt you for:
39
+
40
+ - **Connection name** — the name of your Snowflake connection from `~/.snowflake/connections.toml`
41
+ - **Native app database name** — the database where the DataSecOps Framework app is installed (e.g. `DATA_ENGINEERS_DATASECOPS_FRAMEWORK`)
42
+
43
+ ### 2. Activate the virtual environment
44
+
45
+ **Linux / macOS:**
46
+
47
+ ```bash
48
+ source .venv/bin/activate
49
+ ```
50
+
51
+ **Windows:**
52
+
53
+ ```powershell
54
+ .\.venv\Scripts\Activate.ps1
55
+ ```
56
+
57
+ ### 3. Run the CLI
58
+
59
+ ```bash
60
+ datasecops
61
+ ```
62
+
63
+ This connects to the native app, loads your project configuration, and presents the main menu.
64
+
65
+ ## What the CLI Does
66
+
67
+ ### Main Menu
68
+
69
+ ```
70
+ [1] development - dbt Development Commands
71
+ [2] git - Source Control Operations
72
+ [3] downloads - Download Configs & Skills
73
+ [0] exit - Exit
74
+ ```
75
+
76
+ ### Development Menu
77
+
78
+ Run dbt commands via dbt Fusion:
79
+
80
+ - **run** — full run, modified only (`state:modified+`), or specific models
81
+ - **build** — run + test in one command
82
+ - **test** — all tests or specific selectors
83
+ - **lint** — SQLFluff lint/fix on modified files or entire project
84
+ - **deps** — install dbt packages
85
+ - **seed** — load seed data
86
+ - **compile** — compile models
87
+ - **snapshot** — run snapshots
88
+ - **freshness** — check source freshness
89
+ - **docs** — generate and serve dbt docs
90
+ - **clean / debug / list / retry**
91
+
92
+ ### Git Menu
93
+
94
+ Source control operations via GitPython:
95
+
96
+ - **branching** — create, checkout, switch, delete, prune, reset
97
+ - **commit** — stage all changes, enter message, auto-push
98
+ - **push / pull** — sync with remote
99
+ - **rebase** — standard rebase or squash & rebase with main
100
+ - **deploy** — push to environment branches (dev/test/prod)
101
+ - **squash to test** — squash merge current branch into test
102
+ - **cherry-pick from test** — select and cherry-pick specific commits from test
103
+
104
+ Branch naming follows the convention configured in the native app (e.g. `feature/123_my-feature`).
105
+
106
+ ### Downloads Menu
107
+
108
+ Pull configurations from the native app to your local project:
109
+
110
+ - **SQLFluff config** — downloads linting rules to `.sqlfluff`
111
+ - **Pipeline files** — downloads CI/CD workflows (GitHub Actions or Azure DevOps)
112
+ - **dbt packages** — updates `packages.yml` with versions from the framework, optionally runs `dbt deps`
113
+ - **Cortex Code skills** — list, install, or update framework skills for Cortex Code
114
+
115
+ ## Configuration
116
+
117
+ ### `.datasecops.yml`
118
+
119
+ Created by the setup script in your project root. Contains:
120
+
121
+ ```yaml
122
+ connection_name: "my_connection" # Snowflake connection name
123
+ app_database: "DATA_ENGINEERS_DATASECOPS_FRAMEWORK" # Native app database
124
+ profile_name: "" # Auto-detected from dbt_project.yml
125
+ ```
126
+
127
+ ### `dbt_project.yml`
128
+
129
+ The CLI reads the `profile:` field from your `dbt_project.yml` (looks in both `./dbt_project.yml` and `./dbt/dbt_project.yml`) to determine which project profile to load from the native app.
130
+
131
+ ### Snowflake Connection
132
+
133
+ The CLI uses `snowflake-connector-python` with the connection name from `.datasecops.yml`. Connections are configured in `~/.snowflake/connections.toml`:
134
+
135
+ ```toml
136
+ [my_connection]
137
+ account = "my_account"
138
+ user = "my_user"
139
+ authenticator = "externalbrowser"
140
+ warehouse = "MY_WH"
141
+ role = "MY_ROLE"
142
+ ```
143
+
144
+ ## Project Structure
145
+
146
+ ```
147
+ datasecops-cli/
148
+ ├── pyproject.toml # Package config, dependencies, entry point
149
+ ├── setup.sh # Bash setup (Linux/macOS)
150
+ ├── setup.ps1 # PowerShell setup (Windows)
151
+ ├── .github/workflows/publish-cli.yml # PyPI publish workflow
152
+ └── src/datasecops_cli/
153
+ ├── main.py # Entry point and main menu
154
+ ├── config.py # Configuration loader
155
+ ├── models/ # Pydantic data models
156
+ ├── services/ # Business logic (dbt, git, Snowflake, downloads)
157
+ ├── menus/ # Interactive menu modules
158
+ └── utilities/ # Display, file I/O, YAML helpers
159
+ ```
160
+
161
+ ## Publishing to PyPI
162
+
163
+ The package is published automatically when a tag matching `cli-v*` is pushed:
164
+
165
+ ```bash
166
+ git tag cli-v0.1.0
167
+ git push origin cli-v0.1.0
168
+ ```
169
+
170
+ The GitHub Actions workflow builds the package and publishes to PyPI using OIDC trusted publishing.
171
+
172
+ To build and publish manually:
173
+
174
+ ```bash
175
+ pip install build twine
176
+ python -m build
177
+ twine upload dist/*
178
+ ```
179
+
180
+ ## Native App API
181
+
182
+ The CLI communicates with the native app through stored procedures:
183
+
184
+ | Procedure | Purpose |
185
+ |---|---|
186
+ | `api.get_framework_config(code)` | Fetch any config by code (PROJECT, PIPELINES, SQLFLUFF_RULES, CORTEX_SKILLS, etc.) |
187
+ | `api.get_project_profiles()` | List all project profiles |
188
+ | `api.import_cortex_skills(json)` | Import skills into the native app |
189
+ | `api.fetch_dbt_package_versions(json)` | Fetch latest package versions from GitHub |
190
+
191
+ These procedures are granted to the `data_engineers_framework_admin` application role.
@@ -0,0 +1,23 @@
1
+ under the folder /legacy_framework/app/commandline is the legacy framework which this native app has replaced the configuration for.
2
+
3
+ I want to re-create the command line segment so that users can still use it against the native app.
4
+ It needs to:
5
+ 1 - ensure cortex code, uv and dbt (dbt fusion) is installed. If it isnt then needs to install them
6
+ 2 - select which connection they want to use
7
+ 3 - select the database name for the native app
8
+ 4 - create a venv under uv for the project to run under
9
+ 5 - ensure the packages are installed as defined in settings => requirements of the framework
10
+ 6 - the project profile to use should come from the dbtproject.yml file and needs to ensure a project profile exists inside the framework database
11
+ 7 - display option menus so a user can run dbt or git based commands.
12
+
13
+ For the dbt run commands, the user needs to be able to run them under dbt fusion
14
+ For the git commands, they need to be able to pull, push, checkout etc as per current menus, but they also need to be able to do a squash merge into test and cherry pick commits out of test.
15
+
16
+ We also need the ability to download the config file for SQLFluff as well as the pipeline files and also bring down updated dbt package versions/revisions for the dbt dependancies.
17
+
18
+ step 1, 2, 3, 4 need to be in a setup script (bash & ps based). Then download the framework command line package from pypi
19
+
20
+ Create a plan of what we need to
21
+ - build into the framework command line package
22
+ - deployment path into pypi
23
+ - scripts needed to be included in the local repo