iris-security-sdk 0.2.5__tar.gz → 0.2.11__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: iris-security-sdk
3
- Version: 0.2.5
3
+ Version: 0.2.11
4
4
  Summary: IRIS — AI Agent Governance SDK. Govern AI agents locally.
5
5
  License: Apache-2.0
6
6
  Project-URL: Homepage, https://gimartinb.github.io/iris-sdk/
@@ -16,7 +16,7 @@ Classifier: Programming Language :: Python :: 3.11
16
16
  Classifier: Programming Language :: Python :: 3.12
17
17
  Requires-Python: >=3.10
18
18
  Description-Content-Type: text/markdown
19
- Requires-Dist: iris-security-core>=0.1.13
19
+ Requires-Dist: iris-security-core>=0.1.16
20
20
  Requires-Dist: pyyaml>=6.0
21
21
  Requires-Dist: pydantic>=2.0
22
22
  Requires-Dist: click>=8.1
@@ -47,7 +47,7 @@ from iris_core.evidence.vault import EvidenceVault
47
47
  from iris_core.cost.tracker import CostSummary, CostTracker, CostEntry
48
48
  from iris_core.cost.pricing import PricingRegistry
49
49
 
50
- __version__ = "0.2.5"
50
+ __version__ = "0.2.11"
51
51
  __all__ = [
52
52
  # Main classes
53
53
  "IrisAgent",
@@ -73,8 +73,39 @@ def telemetry_opted_out() -> bool:
73
73
  return os.environ.get("IRIS_TELEMETRY_OPT_OUT", "").strip() in {"1", "true", "yes"}
74
74
 
75
75
 
76
+ def _is_ci_environment() -> bool:
77
+ ci_markers = (
78
+ "CI",
79
+ "CONTINUOUS_INTEGRATION",
80
+ "GITHUB_ACTIONS",
81
+ "GITLAB_CI",
82
+ "JENKINS_URL",
83
+ "BUILDKITE",
84
+ "CIRCLECI",
85
+ "TRAVIS",
86
+ "TEAMCITY_VERSION",
87
+ "AZURE_HTTP_USER_AGENT",
88
+ "CODEBUILD_BUILD_ID",
89
+ )
90
+ return any(os.environ.get(name) for name in ci_markers)
91
+
92
+
93
+ def _is_internal_install() -> bool:
94
+ if os.environ.get("IRIS_TELEMETRY_INTERNAL", "").strip() in {"1", "true", "yes"}:
95
+ return True
96
+
97
+ iris_path = shutil.which("iris") or ""
98
+ path_lower = iris_path.lower()
99
+ internal_markers = ("iris-sdk", "/packages/", "editable")
100
+ return any(marker in path_lower for marker in internal_markers)
101
+
102
+
76
103
  def telemetry_enabled() -> bool:
77
- return TELEMETRY_ENABLED and not telemetry_opted_out()
104
+ if not TELEMETRY_ENABLED or telemetry_opted_out():
105
+ return False
106
+ if _is_ci_environment() or _is_internal_install():
107
+ return False
108
+ return True
78
109
 
79
110
 
80
111
  def _get_or_create_install_id() -> str:
@@ -106,6 +137,8 @@ def _build_payload(event: str) -> dict[str, str]:
106
137
  "platform": sys.platform,
107
138
  "iris_version": _get_iris_version(),
108
139
  "timestamp": datetime.now(timezone.utc).replace(microsecond=0).isoformat(),
140
+ "ci": "true" if _is_ci_environment() else "false",
141
+ "internal": "true" if _is_internal_install() else "false",
109
142
  }
110
143
 
111
144
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: iris-security-sdk
3
- Version: 0.2.5
3
+ Version: 0.2.11
4
4
  Summary: IRIS — AI Agent Governance SDK. Govern AI agents locally.
5
5
  License: Apache-2.0
6
6
  Project-URL: Homepage, https://gimartinb.github.io/iris-sdk/
@@ -16,7 +16,7 @@ Classifier: Programming Language :: Python :: 3.11
16
16
  Classifier: Programming Language :: Python :: 3.12
17
17
  Requires-Python: >=3.10
18
18
  Description-Content-Type: text/markdown
19
- Requires-Dist: iris-security-core>=0.1.13
19
+ Requires-Dist: iris-security-core>=0.1.16
20
20
  Requires-Dist: pyyaml>=6.0
21
21
  Requires-Dist: pydantic>=2.0
22
22
  Requires-Dist: click>=8.1
@@ -8,4 +8,5 @@ iris_security_sdk.egg-info/PKG-INFO
8
8
  iris_security_sdk.egg-info/SOURCES.txt
9
9
  iris_security_sdk.egg-info/dependency_links.txt
10
10
  iris_security_sdk.egg-info/requires.txt
11
- iris_security_sdk.egg-info/top_level.txt
11
+ iris_security_sdk.egg-info/top_level.txt
12
+ tests/test_telemetry.py
@@ -1,4 +1,4 @@
1
- iris-security-core>=0.1.13
1
+ iris-security-core>=0.1.16
2
2
  pyyaml>=6.0
3
3
  pydantic>=2.0
4
4
  click>=8.1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "iris-security-sdk"
7
- version = "0.2.5"
7
+ version = "0.2.11"
8
8
  description = "IRIS — AI Agent Governance SDK. Govern AI agents locally."
9
9
  readme = "README.md"
10
10
  license = { text = "Apache-2.0" }
@@ -26,7 +26,7 @@ classifiers = [
26
26
  "Programming Language :: Python :: 3.12",
27
27
  ]
28
28
  dependencies = [
29
- "iris-security-core>=0.1.13",
29
+ "iris-security-core>=0.1.16",
30
30
  "pyyaml>=6.0",
31
31
  "pydantic>=2.0",
32
32
  "click>=8.1",
@@ -0,0 +1,46 @@
1
+ """Tests for IRIS telemetry opt-out and internal/CI exclusion."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ from unittest.mock import patch
7
+
8
+ import pytest
9
+
10
+ from iris import _telemetry
11
+
12
+
13
+ @pytest.fixture(autouse=True)
14
+ def _reset_env(monkeypatch: pytest.MonkeyPatch) -> None:
15
+ monkeypatch.delenv("IRIS_TELEMETRY_OPT_OUT", raising=False)
16
+ monkeypatch.delenv("IRIS_TELEMETRY_INTERNAL", raising=False)
17
+ monkeypatch.delenv("CI", raising=False)
18
+ monkeypatch.delenv("GITHUB_ACTIONS", raising=False)
19
+
20
+
21
+ def test_telemetry_enabled_by_default() -> None:
22
+ with patch.object(_telemetry, "TELEMETRY_ENABLED", True):
23
+ assert _telemetry.telemetry_enabled() is True
24
+
25
+
26
+ def test_telemetry_opt_out() -> None:
27
+ with patch.dict(os.environ, {"IRIS_TELEMETRY_OPT_OUT": "1"}):
28
+ assert _telemetry.telemetry_enabled() is False
29
+
30
+
31
+ def test_telemetry_skips_ci() -> None:
32
+ with patch.object(_telemetry, "TELEMETRY_ENABLED", True):
33
+ with patch.dict(os.environ, {"GITHUB_ACTIONS": "true"}):
34
+ assert _telemetry.telemetry_enabled() is False
35
+
36
+
37
+ def test_telemetry_skips_internal_flag() -> None:
38
+ with patch.object(_telemetry, "TELEMETRY_ENABLED", True):
39
+ with patch.dict(os.environ, {"IRIS_TELEMETRY_INTERNAL": "1"}):
40
+ assert _telemetry.telemetry_enabled() is False
41
+
42
+
43
+ def test_telemetry_skips_iris_sdk_path() -> None:
44
+ with patch.object(_telemetry, "TELEMETRY_ENABLED", True):
45
+ with patch.object(_telemetry.shutil, "which", return_value="/Users/dev/iris-sdk/.venv/bin/iris"):
46
+ assert _telemetry.telemetry_enabled() is False