secureapp-python-agent 26.5.0rc4__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 (63) hide show
  1. secureapp_python_agent-26.5.0rc4/.editorconfig +10 -0
  2. secureapp_python_agent-26.5.0rc4/.gitignore +151 -0
  3. secureapp_python_agent-26.5.0rc4/.gitlab-ci.yml +249 -0
  4. secureapp_python_agent-26.5.0rc4/.o11y-doctor.yaml +20 -0
  5. secureapp_python_agent-26.5.0rc4/.service-manifests/python-agent-component.yaml +20 -0
  6. secureapp_python_agent-26.5.0rc4/CODEOWNERS +1 -0
  7. secureapp_python_agent-26.5.0rc4/LICENSE +2 -0
  8. secureapp_python_agent-26.5.0rc4/Makefile +231 -0
  9. secureapp_python_agent-26.5.0rc4/PKG-INFO +259 -0
  10. secureapp_python_agent-26.5.0rc4/README.md +213 -0
  11. secureapp_python_agent-26.5.0rc4/buildAll.sh +7 -0
  12. secureapp_python_agent-26.5.0rc4/buildO11y.sh +5 -0
  13. secureapp_python_agent-26.5.0rc4/buildPublish.sh +25 -0
  14. secureapp_python_agent-26.5.0rc4/dev/benchmarks/__init__.py +30 -0
  15. secureapp_python_agent-26.5.0rc4/dev/benchmarks/benchmark_agent.py +190 -0
  16. secureapp_python_agent-26.5.0rc4/dev/benchmarks/benchmark_dependency_analyzer.py +303 -0
  17. secureapp_python_agent-26.5.0rc4/dev/benchmarks/benchmark_suite.py +197 -0
  18. secureapp_python_agent-26.5.0rc4/dev/benchmarks/conftest.py +125 -0
  19. secureapp_python_agent-26.5.0rc4/dev/compat_test_1.35.0.py +267 -0
  20. secureapp_python_agent-26.5.0rc4/dev/compat_test_1.39.0.py +348 -0
  21. secureapp_python_agent-26.5.0rc4/dev/data/golden-data.csv +23 -0
  22. secureapp_python_agent-26.5.0rc4/dev/debug/debug_analyzer.py +219 -0
  23. secureapp_python_agent-26.5.0rc4/dev/debug/utils.py +148 -0
  24. secureapp_python_agent-26.5.0rc4/dev/scripts/check_license.py +102 -0
  25. secureapp_python_agent-26.5.0rc4/dev/scripts/update_deps.py +108 -0
  26. secureapp_python_agent-26.5.0rc4/docker/Dockerfile.agentic-ai +43 -0
  27. secureapp_python_agent-26.5.0rc4/docker/Dockerfile.manual +38 -0
  28. secureapp_python_agent-26.5.0rc4/docker/Dockerfile.zero-code +42 -0
  29. secureapp_python_agent-26.5.0rc4/docker-compose.yml +113 -0
  30. secureapp_python_agent-26.5.0rc4/examples/README.md +77 -0
  31. secureapp_python_agent-26.5.0rc4/examples/common_flask_utils.py +180 -0
  32. secureapp_python_agent-26.5.0rc4/examples/manual_flask_app.py +163 -0
  33. secureapp_python_agent-26.5.0rc4/examples/requirements.txt +20 -0
  34. secureapp_python_agent-26.5.0rc4/examples/zero_code_agentic_ai_app.py +334 -0
  35. secureapp_python_agent-26.5.0rc4/examples/zero_code_flask_app.py +43 -0
  36. secureapp_python_agent-26.5.0rc4/o11y_test_application/otel-collector/splunk-otel-config.yaml +57 -0
  37. secureapp_python_agent-26.5.0rc4/o11y_test_application/otel-collector/start-splunk-otel-collector.sh +16 -0
  38. secureapp_python_agent-26.5.0rc4/o11y_test_application/requirements.txt +11 -0
  39. secureapp_python_agent-26.5.0rc4/o11y_test_application/runit.sh +30 -0
  40. secureapp_python_agent-26.5.0rc4/o11y_test_application/test_application.py +25 -0
  41. secureapp_python_agent-26.5.0rc4/otel-collector-config.yml +50 -0
  42. secureapp_python_agent-26.5.0rc4/pyproject.toml +223 -0
  43. secureapp_python_agent-26.5.0rc4/renovate.json +21 -0
  44. secureapp_python_agent-26.5.0rc4/setup.cfg +4 -0
  45. secureapp_python_agent-26.5.0rc4/sonar-project.properties +3 -0
  46. secureapp_python_agent-26.5.0rc4/src/secureapp_python_agent.egg-info/PKG-INFO +259 -0
  47. secureapp_python_agent-26.5.0rc4/src/secureapp_python_agent.egg-info/SOURCES.txt +61 -0
  48. secureapp_python_agent-26.5.0rc4/src/secureapp_python_agent.egg-info/dependency_links.txt +1 -0
  49. secureapp_python_agent-26.5.0rc4/src/secureapp_python_agent.egg-info/entry_points.txt +5 -0
  50. secureapp_python_agent-26.5.0rc4/src/secureapp_python_agent.egg-info/requires.txt +28 -0
  51. secureapp_python_agent-26.5.0rc4/src/secureapp_python_agent.egg-info/top_level.txt +1 -0
  52. secureapp_python_agent-26.5.0rc4/src/splunk_secureapp_opentelemetry_extension/__init__.py +38 -0
  53. secureapp_python_agent-26.5.0rc4/src/splunk_secureapp_opentelemetry_extension/agent.py +304 -0
  54. secureapp_python_agent-26.5.0rc4/src/splunk_secureapp_opentelemetry_extension/dependency_analyzer.py +528 -0
  55. secureapp_python_agent-26.5.0rc4/src/splunk_secureapp_opentelemetry_extension/environment_variables.py +59 -0
  56. secureapp_python_agent-26.5.0rc4/src/splunk_secureapp_opentelemetry_extension/py.typed +0 -0
  57. secureapp_python_agent-26.5.0rc4/src/splunk_secureapp_opentelemetry_extension/utils.py +86 -0
  58. secureapp_python_agent-26.5.0rc4/tests/__init__.py +6 -0
  59. secureapp_python_agent-26.5.0rc4/tests/test_agent.py +715 -0
  60. secureapp_python_agent-26.5.0rc4/tests/test_dependency_analyzer.py +1604 -0
  61. secureapp_python_agent-26.5.0rc4/tests/test_environment_variables.py +74 -0
  62. secureapp_python_agent-26.5.0rc4/tests/test_integration.py +436 -0
  63. secureapp_python_agent-26.5.0rc4/tests/test_package_import.py +78 -0
@@ -0,0 +1,10 @@
1
+ # EditorConfig helps maintain consistent coding styles
2
+ root = true
3
+
4
+ [*]
5
+ charset = utf-8
6
+ end_of_line = lf
7
+ insert_final_newline = true
8
+ indent_style = space
9
+ indent_size = 4
10
+ trim_trailing_whitespace = true
@@ -0,0 +1,151 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
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
+ *.egg-info/
24
+ .installed.cfg
25
+ *.egg
26
+ MANIFEST
27
+
28
+ # Virtual environments
29
+ venv/
30
+ env/
31
+ ENV/
32
+ .venv/
33
+ .env/
34
+
35
+ # PyInstaller
36
+ *.manifest
37
+ *.spec
38
+
39
+ # Installer logs
40
+ pip-log.txt
41
+ pip-delete-this-directory.txt
42
+
43
+ # Unit test / coverage reports
44
+ htmlcov/
45
+ .tox/
46
+ .nox/
47
+ .coverage
48
+ .coverage.*
49
+ .cache
50
+ nosetests.xml
51
+ coverage.xml
52
+ *.cover
53
+ pytest-results.xml
54
+ .hypothesis/
55
+ .pytest_cache/
56
+ .testmondata
57
+
58
+ # Setuptools-scm auto-generated version file
59
+ src/splunk_secureapp_opentelemetry_extension/_version.py
60
+
61
+ # Translations
62
+ *.mo
63
+ *.pot
64
+
65
+ # Django stuff:
66
+ *.log
67
+ local_settings.py
68
+ db.sqlite3
69
+
70
+ # Flask stuff:
71
+ instance/
72
+ .webassets-cache
73
+
74
+ # Scrapy stuff:
75
+ .scrapy
76
+
77
+ # Sphinx documentation
78
+ docs/_build/
79
+
80
+ # PyBuilder
81
+ target/
82
+
83
+ # Jupyter Notebook
84
+ .ipynb_checkpoints
85
+
86
+ # IPython
87
+ profile_default/
88
+ ipython_config.py
89
+
90
+ # pyenv
91
+ .python-version
92
+
93
+ # celery beat schedule file
94
+ celerybeat-schedule
95
+
96
+ # SageMath parsed files
97
+ *.sage.py
98
+
99
+ # Spyder project settings
100
+ .spyderproject
101
+ .spyproject
102
+
103
+ # Rope project settings
104
+ .ropeproject
105
+
106
+ # mkdocs documentation
107
+ /site
108
+
109
+ # mypy
110
+ .mypy_cache/
111
+ .dmypy.json
112
+ dmypy.json
113
+
114
+ # Pyre type checker
115
+ .pyre/
116
+
117
+ # IDE files
118
+ .vscode/
119
+ .idea/
120
+ *.swp
121
+ *.swo
122
+ *~
123
+
124
+ # macOS
125
+ .DS_Store
126
+
127
+ # Windows
128
+ Thumbs.db
129
+ ehthumbs.db
130
+ Desktop.ini
131
+
132
+ # Security reports
133
+ bandit-report.json
134
+ safety-report.json
135
+
136
+ # Temporary files
137
+ *.tmp
138
+ *.temp
139
+ .temp/
140
+
141
+ # Local configuration and logs
142
+ logs/
143
+ .env.local
144
+ .env.*.local
145
+
146
+ # Backup files
147
+ *.bak
148
+ *.backup
149
+
150
+ # Logs directory for logging
151
+ logs/*
@@ -0,0 +1,249 @@
1
+ include:
2
+ - project: observability/shared/gitlab-jobs
3
+ ref: 3.1.15
4
+ file:
5
+ - oss-scan-template.yml
6
+ - sast-scan-template.yml
7
+ - template: "Workflows/MergeRequest-Pipelines.gitlab-ci.yml"
8
+ - project: ci-cd/templates
9
+ file: /cicd/sonarqube-3.0.1.yml
10
+
11
+ variables:
12
+ # Using Python 3.13 with trixie (Debian 13) base
13
+ PY3_IMAGE: docker.repo.splunkdev.net/ci-cd/ci-container/python-3.13-trixie:5.3.0
14
+ # Ensure full git history for setuptools-scm versioning
15
+ GIT_DEPTH: 0
16
+ # Set cache configuration
17
+ CACHE_KEY: ${CI_COMMIT_REF_SLUG}
18
+ CACHE_PATHS: ".pip-cache/"
19
+ ENABLE_SONARQUBE:
20
+ value: "true"
21
+ options:
22
+ - "true"
23
+ - "false"
24
+ description: >-
25
+ Enable SonarQube code quality scanning. Set to 'false' to disable.
26
+
27
+ image: ${PY3_IMAGE}
28
+
29
+ stages:
30
+ - code_analysis
31
+ - test
32
+ - build
33
+ - publish
34
+
35
+ # Enable caching to speed up dependency installation
36
+ cache:
37
+ key: ${CACHE_KEY}
38
+ paths:
39
+ - ${CACHE_PATHS}
40
+ when: always
41
+
42
+ # Global before_script for dependency installation optimization
43
+ .base_setup: &base_setup
44
+ before_script:
45
+ - mkdir -p .pip-cache
46
+ - pip config set global.cache-dir .pip-cache
47
+ - make venv-install
48
+
49
+ # Core unit tests with coverage validation
50
+ test:unit:
51
+ stage: test
52
+ <<: *base_setup
53
+ script:
54
+ - make all # Runs format, lint, typecheck, test with 85% coverage
55
+ coverage: '/TOTAL.*\s+(\d+%)$/'
56
+ artifacts:
57
+ reports:
58
+ junit: pytest-results.xml # Added for better GitLab test integration
59
+ coverage_report:
60
+ coverage_format: cobertura
61
+ path: coverage.xml
62
+ paths:
63
+ - htmlcov/
64
+ - coverage.xml
65
+ rules:
66
+ - if: $CI_PIPELINE_SOURCE == "schedule"
67
+ when: never
68
+ - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
69
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
70
+ - if: $CI_COMMIT_TAG
71
+
72
+ # Build stage with proper dependencies
73
+ build:wheel:
74
+ stage: build
75
+ needs:
76
+ - semgrep
77
+ - test:unit # Ensures tests pass with 85% coverage
78
+ <<: *base_setup
79
+ script:
80
+ - |
81
+ if [ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]; then
82
+ gitversion --prefix v bump auto
83
+ eval $(ssh-agent -s)
84
+ go-go tag --skip-ci
85
+ else
86
+ echo "Not on main branch. Skipping main-only steps."
87
+ fi
88
+ - make build
89
+ artifacts:
90
+ paths:
91
+ - dist/
92
+ rules:
93
+ - if: $CI_PIPELINE_SOURCE == "schedule"
94
+ when: never
95
+ - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
96
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
97
+ - if: $CI_COMMIT_TAG
98
+
99
+ # Shared publish template to reduce duplication
100
+ .publish_template: &publish_template
101
+ stage: publish
102
+ <<: *base_setup
103
+ script:
104
+ - venv/bin/python -m twine check dist/*
105
+ - venv/bin/python -m twine upload --verbose --non-interactive ${TWINE_REPOSITORY_URL:+--skip-existing} dist/*
106
+ # testPypi - using variable set TEST_TWINE_PASSWORD to API TOKEN
107
+ publish:test:
108
+ <<: *publish_template
109
+ needs:
110
+ - job: build:wheel
111
+ artifacts: true
112
+ variables:
113
+ TWINE_USERNAME: __token__
114
+ TWINE_PASSWORD: $TEST_TWINE_PASSWORD
115
+ TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
116
+ rules:
117
+ - if: $CI_PIPELINE_SOURCE == "schedule"
118
+ when: never
119
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
120
+ # pypi - using o11y-gdi set API TOKEN
121
+ # change back - if: $CI_COMMIT_TAG - this is test - to launch
122
+ publish:production:
123
+ <<: *publish_template
124
+ needs:
125
+ - job: build:wheel
126
+ artifacts: true
127
+ variables:
128
+ TWINE_USERNAME: __token__
129
+ TWINE_PASSWORD: $TWINE_PASSWORD
130
+ rules:
131
+ - if: $CI_PIPELINE_SOURCE == "schedule"
132
+ when: never
133
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
134
+
135
+ # Python version compatibility matrix testing
136
+ test:python-matrix:
137
+ stage: test
138
+ image: docker.repo.splunkdev.net/ci-cd/ci-container/python-${PYTHON_VERSION}-trixie:5.3.0
139
+ needs:
140
+ - test:unit # Explicit dependency for better pipeline visualization
141
+ <<: *base_setup
142
+ script:
143
+ - make test # Run tests for the specific Python version in this container
144
+ artifacts:
145
+ reports:
146
+ junit: pytest-results.xml
147
+ paths:
148
+ - htmlcov/
149
+ - coverage.xml
150
+ parallel:
151
+ matrix:
152
+ - PYTHON_VERSION: ["3.10", "3.11", "3.12", "3.13", "3.14"]
153
+ rules:
154
+ # Run on main branch for comprehensive validation
155
+ - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
156
+ # Run on git tags to ensure release compatibility
157
+ - if: $CI_COMMIT_TAG
158
+ # Manual trigger for merge requests (allow_failure for optional testing)
159
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
160
+
161
+ # Add OpenTelemetry version compatibility testing
162
+ test:otel-versions:
163
+ stage: test
164
+ image: ${PY3_IMAGE}
165
+ needs:
166
+ - test:unit
167
+ <<: *base_setup
168
+ script:
169
+ - pip uninstall -y opentelemetry-api opentelemetry-sdk opentelemetry-exporter-otlp
170
+ - pip install opentelemetry-api==${OTEL_VERSION} opentelemetry-sdk==${OTEL_VERSION} opentelemetry-exporter-otlp==${OTEL_VERSION}
171
+ - echo "Installed OpenTelemetry packages:"
172
+ - pip show opentelemetry-api | grep "Version"
173
+ - pip show opentelemetry-sdk | grep "Version"
174
+ - pip show opentelemetry-exporter-otlp | grep "Version"
175
+ - make test
176
+ parallel:
177
+ matrix:
178
+ - OTEL_VERSION: ["1.27.0", "1.30.0", "1.35.0", "1.38.0", "1.39.0", "1.39.1"]
179
+ rules:
180
+ # Run on main branch for comprehensive validation
181
+ - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
182
+ # Run on git tags to ensure release compatibility
183
+ - if: $CI_COMMIT_TAG
184
+ # Manual trigger for merge requests
185
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
186
+ when: manual
187
+ allow_failure: true
188
+
189
+ # Performance benchmarks and validation
190
+ test:benchmarks:
191
+ stage: test
192
+ needs:
193
+ - test:unit # Ensure core tests pass before performance testing
194
+ <<: *base_setup
195
+ script:
196
+ - make benchmark # Runs performance benchmarks with mocking
197
+ artifacts:
198
+ reports:
199
+ junit: dev/benchmarks/results/benchmark-results.xml
200
+ paths:
201
+ - dev/benchmarks/results/
202
+ variables:
203
+ # Performance testing configuration
204
+ SPLUNK_SECUREAPP_DEPENDENCY_INITIAL_DELAY: "1"
205
+ SPLUNK_SECUREAPP_DEPENDENCY_SCAN_INTERVAL: "30"
206
+ rules:
207
+ # Run performance tests on main branch
208
+ - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
209
+ when: manual
210
+ allow_failure: true
211
+ # Run on git tags to validate release performance
212
+ - if: $CI_COMMIT_TAG
213
+ when: manual
214
+ allow_failure: true
215
+ # Optional for merge requests
216
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
217
+ when: manual
218
+ allow_failure: true
219
+
220
+ sonarqube:
221
+ stage: test
222
+ interruptible: true
223
+ allow_failure: true
224
+ needs:
225
+ - job: test:unit
226
+ optional: true
227
+ artifacts: true
228
+ rules:
229
+ - if: $ENABLE_SONARQUBE != "true"
230
+ when: never
231
+ - if: $CI_COMMIT_TAG
232
+ - if: $CI_MERGE_REQUEST_IID
233
+ - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
234
+ script:
235
+ - |
236
+ SONAR_ARGS="-Dsonar.qualitygate.wait=true"
237
+ if [ -n "$CI_COMMIT_TAG" ]; then
238
+ SONAR_ARGS="${SONAR_ARGS} -Dsonar.branch.name=${CI_DEFAULT_BRANCH}"
239
+ echo "Tag detected: reporting analysis to branch ${CI_DEFAULT_BRANCH}"
240
+ elif [ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ]; then
241
+ SONAR_ARGS="${SONAR_ARGS} -Dsonar.branch.name=${CI_DEFAULT_BRANCH}"
242
+ echo "Default branch: reporting analysis to branch ${CI_DEFAULT_BRANCH}"
243
+ fi
244
+ sonar-scanner -Dsonar.token="$SONAR_LOGIN_TOKEN" ${SONAR_ARGS}
245
+ artifacts:
246
+ paths:
247
+ - .scannerwork/
248
+ when: on_failure
249
+ expire_in: 7 days
@@ -0,0 +1,20 @@
1
+ # The Doctor (http://go/the-doctor) configuration for this repository
2
+
3
+ assignMergeRequestReviewersFromGroups:
4
+ groups:
5
+ - sg-cloud-o11y-secureapp-dev
6
+ ignoreLabels:
7
+ - dependency-update
8
+ except:
9
+ - bot_polyjuice
10
+
11
+ closeStaleMergeRequests:
12
+ staleAfterDays: 28
13
+ closeAfterStaleDays: 7
14
+
15
+ unassignReviewersFromDrafts: {}
16
+
17
+ assignUnassignedMergeRequests: {}
18
+
19
+ approveRenovateUpdates:
20
+ requireLabel: auto-merge-enabled
@@ -0,0 +1,20 @@
1
+ ---
2
+ apiVersion: backstage.io/v1alpha1
3
+ kind: Component
4
+ metadata:
5
+ name: secure-app-python
6
+ title: secure-app-python
7
+ functionalDomain:
8
+ - o11y
9
+ description: This is secureapp backend
10
+ annotations:
11
+ backstage.io/source-location: url:https://cd.splunkdev.com/o11y-gdi/secure-app-python
12
+ splunk.com/issue-tracker-url: https://splunk.atlassian.net/jira/software/c/projects
13
+ splunk.com/slack-url: http://go/slack/o11y-app-platform
14
+ backstage.io/view-url: https://cd.splunkdev.com/o11y-gdi/secure-app-python/.service-manifests/python-agent-component.yaml
15
+ backstage.io/edit-url: https://cd.splunkdev.com/o11y-gdi/secure-app-python/.service-manifests/python-agent-component.yaml
16
+ links: []
17
+ spec:
18
+ lifecycle: experimental
19
+ type: service
20
+ owner: group:sg-cloud-o11y-secureapp-dev
@@ -0,0 +1 @@
1
+ * @okta-groups/sg-cloud-o11y-secureapp-dev @okta-groups/sg-cloud-o11y-gdi-eng
@@ -0,0 +1,2 @@
1
+
2
+ The terms governing use of the code is at this site: https://www.splunk.com/en_us/legal/splunk-general-terms.html
@@ -0,0 +1,231 @@
1
+ # Makefile for Splunk SecureApp Python Agent Development
2
+
3
+ VENV_NAME ?= venv
4
+ VENV_DIR := $(VENV_NAME)
5
+ PYTHON := $(VENV_DIR)/bin/python
6
+ PIP := $(VENV_DIR)/bin/pip
7
+
8
+ # OpenTelemetry packages for version testing
9
+ OTEL_PACKAGES := opentelemetry-api opentelemetry-sdk opentelemetry-exporter-otlp
10
+
11
+ # Reusable functions
12
+ define install_otel_version
13
+ $(PYTHON) -m pip uninstall -y $(OTEL_PACKAGES)
14
+ $(PYTHON) -m pip install $(foreach pkg,$(OTEL_PACKAGES),$(pkg)==$(1))
15
+ endef
16
+
17
+ define restore_deps
18
+ @echo "๐Ÿ”„ Restoring original dependencies..."
19
+ $(PYTHON) -m pip uninstall -y $(OTEL_PACKAGES)
20
+ $(PYTHON) -m pip install -e .
21
+ endef
22
+
23
+ .PHONY: help venv-install test test-matrix tox lint format typecheck \
24
+ check-license build clean all benchmark debug debug-packages debug-performance \
25
+ publish validate-env show-version test-otel-versions quick-test venv-update \
26
+ test-otel-version test-local-otel-matrix
27
+
28
+ help:
29
+ @echo "SecureApp Python Agent - Development Commands"
30
+ @echo ""
31
+ @echo "๐Ÿš€ Quick Start:"
32
+ @echo " make venv-install # One-time setup: creates venv + installs all dependencies"
33
+ @echo " make all # Complete validation pipeline (matches GitLab CI exactly)"
34
+ @echo ""
35
+ @echo "๐Ÿ“‹ Setup & Environment:"
36
+ @echo " venv-install - Setup development environment with all dependencies"
37
+ @echo " venv-update - Update existing venv with new dependencies (faster than reinstall)"
38
+ @echo " validate-env - Validate Python version and tool availability"
39
+ @echo ""
40
+ @echo "๐Ÿงช Testing Commands:"
41
+ @echo " all - Complete validation: format โ†’ lint โ†’ typecheck โ†’ test (85% coverage)"
42
+ @echo " test - Run tests with 85% coverage requirement"
43
+ @echo " quick-test - Run only tests affected by recent changes (fastest for development)"
44
+ @echo ""
45
+ @echo "๐Ÿ”ฌ Compatibility Testing:"
46
+ @echo " test-matrix - Run tests across all Python versions (PARALLEL: faster, uses tox -p auto)"
47
+ @echo " tox - Run tests across all Python versions (SEQUENTIAL: slower, clearer output)"
48
+ @echo " test-otel-versions - Test with different OpenTelemetry versions"
49
+ @echo " test-otel-version - Test with a specific OpenTelemetry version (OTEL_VERSION=X.Y.Z)"
50
+ @echo " test-local-otel-matrix - Run full OTel version matrix tests locally"
51
+ @echo ""
52
+ @echo "๐Ÿ”ง Code Quality:"
53
+ @echo " format - Format code with ruff (auto-fixes style issues)"
54
+ @echo " lint - Run linting with auto-fix (catches bugs + style violations)"
55
+ @echo " typecheck - Run type checking with mypy (ensures type safety)"
56
+ @echo " check-license - Verify and add license headers to Python files"
57
+ @echo ""
58
+ @echo "๐Ÿš€ Performance & Analysis:"
59
+ @echo " benchmark - Run complete benchmark suite (startup, memory, CPU impact)"
60
+ @echo " debug - Interactive debug analyzer (explore runtime state)"
61
+ @echo ""
62
+ @echo "๐Ÿ” Debug & Troubleshooting:"
63
+ @echo " debug-packages - Show current runtime package analysis"
64
+ @echo " debug-performance - Run performance analysis"
65
+ @echo ""
66
+ @echo "๐Ÿ“ฆ Build & Release:"
67
+ @echo " build - Build distribution packages (wheel + sdist)"
68
+ @echo " publish - Publish package to Artifactory (requires credentials)"
69
+ @echo " clean - Clean all build artifacts and caches (preserves venv)"
70
+ @echo " show-version - Show current version from setuptools-scm"
71
+ @echo ""
72
+ @echo "๐Ÿ’ก Common Workflows:"
73
+ @echo " โ€ข Daily Development: make quick-test โ†’ make all"
74
+ @echo " โ€ข Before Committing: make all"
75
+ @echo " โ€ข OpenTelemetry Changes: make test-otel-versions"
76
+ @echo " โ€ข Python Version Testing: make tox (tests Python 3.10-3.14)"
77
+ @echo " โ€ข Performance Validation: make benchmark or tox -e benchmark"
78
+ @echo " โ€ข Environment Update: make venv-update โ†’ make validate-env"
79
+ @echo ""
80
+ @echo "๐Ÿ“Š Requirements:"
81
+ @echo " โ€ข Performance: <100ms startup, <10MB memory, 85%+ coverage"
82
+ @echo " โ€ข Compatibility: Python 3.10-3.14, OpenTelemetry 1.27.0-1.39.x (tested up to 1.39.1)"
83
+
84
+ # Setup development environment (one command for new developers)
85
+ $(PYTHON):
86
+ @echo "๐Ÿ” Creating virtual environment..."
87
+ python3 -m venv $(VENV_DIR)
88
+ $(PIP) install --upgrade pip
89
+
90
+ venv-install: $(PYTHON)
91
+ $(PIP) install -e .[dev]
92
+ @echo "โœ… Development environment ready!"
93
+ @echo "Run 'make all' to validate your setup."
94
+
95
+ # Update existing venv with new dependencies (faster than reinstall)
96
+ venv-update: $(PYTHON)
97
+ @echo "๐Ÿ”„ Updating virtual environment dependencies..."
98
+ $(PIP) install --upgrade pip
99
+ $(PIP) install -e .[dev] --upgrade
100
+ @echo "โœ… Dependencies updated!"
101
+
102
+ # Core development workflow
103
+ test:
104
+ $(PYTHON) -m pytest tests --junit-xml=pytest-results.xml
105
+
106
+ # Run only tests affected by recent changes (fastest for development)
107
+ quick-test:
108
+ @echo "๐Ÿš€ Running only tests affected by recent changes..."
109
+ $(PYTHON) -m pytest tests -xvs --testmon --no-cov
110
+
111
+ tox:
112
+ tox
113
+
114
+ lint:
115
+ $(PYTHON) -m ruff check src tests dev --fix
116
+
117
+ format:
118
+ $(PYTHON) -m ruff format src tests dev
119
+
120
+ typecheck:
121
+ $(PYTHON) -m mypy src tests
122
+
123
+ check-license:
124
+ @echo "๐Ÿ” Checking license headers..."
125
+ @echo "Files being checked: src/ tests/ dev/ examples/"
126
+ find src tests dev examples -name "*.py" -type f -exec $(PYTHON) dev/scripts/check_license.py {} +
127
+ @echo "โœ… License check complete"
128
+
129
+ # Build distribution packages
130
+ build:
131
+ $(PYTHON) -m build
132
+
133
+ clean:
134
+ @echo "๐Ÿงน Cleaning build artifacts and caches..."
135
+ rm -rf build/ dist/ *.egg-info/ src/*.egg-info/ venv/ logs/
136
+ rm -rf .coverage* .testmondata pytest-results.xml htmlcov/ coverage.xml .pytest_cache/ .mypy_cache/ .ruff_cache/ .tox/
137
+ rm -rf tests/htmlcov/ tests/coverage.xml tests/.coverage
138
+ rm -rf dev/benchmarks/results/ dev/benchmarks/.pytest_cache/
139
+ rm -f src/splunk_secureapp_opentelemetry_extension/_version.py
140
+ rm -f o11y_test_application/otel-collector/otelcol_darwin_amd64
141
+ rm -f o11y_test_application/otel-collector/out.txt
142
+ find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
143
+ find . -type f -name "*.pyc" -delete 2>/dev/null || true
144
+ find . -type f -name "*.pyo" -delete 2>/dev/null || true
145
+ find . -type f -name "*.orig" -delete 2>/dev/null || true
146
+ find . -type f -name "*.rej" -delete 2>/dev/null || true
147
+ find . -type f -name ".DS_Store" -delete 2>/dev/null || true
148
+ @echo "โœ… Clean complete"
149
+
150
+ # Complete validation pipeline - enforces 85% coverage
151
+ all: format lint typecheck test
152
+ @echo "โœ… All checks passed! (format โ†’ lint โ†’ typecheck โ†’ test with 85% coverage)"
153
+
154
+ # Performance benchmarks
155
+ benchmark:
156
+ @echo "๐Ÿš€ Running benchmark suite..."
157
+ $(PYTHON) dev/benchmarks/benchmark_suite.py
158
+
159
+ # Debug and analysis tools
160
+ debug:
161
+ @echo "๐Ÿ” Starting debug analyzer..."
162
+ $(PYTHON) dev/debug/debug_analyzer.py --analyze
163
+
164
+ debug-packages:
165
+ @echo "๐Ÿ“ฆ Analyzing runtime packages..."
166
+ $(PYTHON) dev/debug/debug_analyzer.py
167
+
168
+ debug-performance:
169
+ @echo "โšก Running performance analysis..."
170
+ $(PYTHON) dev/debug/debug_analyzer.py --performance
171
+
172
+ # CI/CD Publishing target - called from gitlab - do we still need this? Check this -check this3 -checkthis5
173
+ publish:
174
+ @echo "๐Ÿ“ฆ Publishing package to repository: $(if $(REPOSITORY),$(REPOSITORY),local)..."
175
+ $(PYTHON) -m twine upload dist/* $(if $(REPOSITORY),--repository $(REPOSITORY),--repository local)
176
+
177
+ # CI/CD Publishing target - added to go to real test pypi - config set in .pypirc - called by buildPublish.sh testpypi
178
+ publish_testpypi:
179
+ @echo "๐Ÿ“ฆ Publishing package to repository: testpypi..."
180
+ $(PYTHON) -m twine upload dist/* --repository testpypi
181
+
182
+ # Matrix testing across Python versions (for advanced CI)
183
+ test-matrix:
184
+ @echo "๐Ÿ”ฌ Running matrix tests..."
185
+ tox -p auto
186
+
187
+ # Test with different OpenTelemetry versions
188
+ test-otel-versions:
189
+ @echo "๐Ÿ”ฌ Testing across OpenTelemetry versions (1.27.0 to 1.35.0)..."
190
+ $(call install_otel_version,1.27.0)
191
+ @echo "โœ… Testing with OpenTelemetry 1.27.0..."
192
+ $(PYTHON) -m pytest tests --no-cov
193
+ $(call install_otel_version,1.35.0)
194
+ @echo "โœ… Testing with OpenTelemetry 1.35.0..."
195
+ $(PYTHON) -m pytest tests --no-cov
196
+ $(call restore_deps)
197
+ @echo "โœ… OpenTelemetry compatibility testing completed successfully!"
198
+
199
+ # Test with a specific OpenTelemetry version
200
+ test-otel-version:
201
+ @test -n "$(OTEL_VERSION)" || (echo "โŒ Error: OTEL_VERSION not specified" && echo "Usage: make test-otel-version OTEL_VERSION=X.Y.Z" && exit 1)
202
+ @echo "๐Ÿ”ฌ Testing with OpenTelemetry $(OTEL_VERSION)..."
203
+ $(call install_otel_version,$(OTEL_VERSION))
204
+ @$(PYTHON) -c "from importlib.metadata import distributions; pkgs=sorted('{}=={}'.format(name, d.version) for d in distributions() for name in [d.metadata.get('Name') or ''] if 'opentelemetry' in name.lower()); print('โœ… Installed:', ', '.join(pkgs))"
205
+ $(PYTHON) -m pytest tests
206
+ $(call restore_deps)
207
+ @echo "โœ… OpenTelemetry compatibility testing completed successfully!"
208
+
209
+ # Run local OpenTelemetry matrix testing
210
+ test-local-otel-matrix:
211
+ @echo "๐Ÿ”ฌ Running full OpenTelemetry version matrix tests locally..."
212
+ @for version in 1.27.0 1.30.0 1.35.0 1.38.0 1.39.0 1.39.1; do \
213
+ echo "๐Ÿ”ฌ Testing with OpenTelemetry $$version..."; \
214
+ $(PYTHON) -m pip uninstall -y $(OTEL_PACKAGES); \
215
+ $(PYTHON) -m pip install $(foreach pkg,$(OTEL_PACKAGES),$(pkg)==$$version); \
216
+ $(PYTHON) -m pytest tests --no-cov || exit 1; \
217
+ done
218
+ $(call restore_deps)
219
+ @echo "โœ… OpenTelemetry matrix testing completed successfully!"
220
+
221
+ # Validate environment and dependencies
222
+ validate-env:
223
+ @echo "โœ… Validating environment..."
224
+ @$(PYTHON) --version
225
+ @$(PYTHON) -c "import sys; print(f'Python: {sys.version}')"
226
+ @$(PYTHON) -c "import pytest, ruff, mypy; print('โœ… All dev tools available')"
227
+
228
+ # Release Management Commands (Git Tag-Based Versioning)
229
+ show-version:
230
+ @echo "๐Ÿ“… Current version from setuptools-scm:"
231
+ @$(PYTHON) -m setuptools_scm || echo "Unable to determine version (no git tags yet)"