switch-trust-cli 1.7.0__py3-none-any.whl

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 (157) hide show
  1. switch_trust/__init__.py +0 -0
  2. switch_trust/cli/__init__.py +0 -0
  3. switch_trust/cli/__main__.py +3 -0
  4. switch_trust/cli/builtin_config.json +879 -0
  5. switch_trust/cli/console.py +127 -0
  6. switch_trust/cli/eval_cli.py +905 -0
  7. switch_trust/cli/file_filter.py +172 -0
  8. switch_trust/cli/init_cli.py +156 -0
  9. switch_trust/cli/main.py +384 -0
  10. switch_trust/cli/output_formatters.py +482 -0
  11. switch_trust/cli/rich_observer.py +89 -0
  12. switch_trust/cli/runner.py +274 -0
  13. switch_trust/cli/scan_cli.py +314 -0
  14. switch_trust/cli/telemetry.py +430 -0
  15. switch_trust/cli/utils.py +158 -0
  16. switch_trust/cli/version.py +1 -0
  17. switch_trust/data/detector_prompts/llm01_adversarial.txt +59 -0
  18. switch_trust/data/detector_prompts/llm01_fixed.txt +6 -0
  19. switch_trust/data/detector_prompts/llm02_adversarial.txt +79 -0
  20. switch_trust/data/detector_prompts/llm02_fixed.txt +6 -0
  21. switch_trust/data/detector_prompts/llm05_adversarial.txt +67 -0
  22. switch_trust/data/detector_prompts/llm05_fixed.txt +14 -0
  23. switch_trust/data/detector_prompts/llm06_adversarial.txt +139 -0
  24. switch_trust/data/detector_prompts/llm06_fixed.txt +13 -0
  25. switch_trust/data/detector_prompts/llm07_adversarial.txt +189 -0
  26. switch_trust/data/detector_prompts/llm07_fixed.txt +12 -0
  27. switch_trust/data/detector_prompts/llm09_adversarial.txt +83 -0
  28. switch_trust/data/detector_prompts/llm09_fixed.txt +13 -0
  29. switch_trust/data/llm01_prompt_injection.csv +6708 -0
  30. switch_trust/data/llm02_sensitive_information.csv +1069 -0
  31. switch_trust/data/llm05_unsafe_output.csv +3882 -0
  32. switch_trust/data/llm06_excessive_agency.csv +778 -0
  33. switch_trust/data/llm07_system_prompt_leakage.csv +971 -0
  34. switch_trust/data/llm09_hallucination-goals.csv +32419 -0
  35. switch_trust/data/llm09_hallucination.csv +599 -0
  36. switch_trust/data/pii_leakage.csv +706 -0
  37. switch_trust/data/secret_leakage.csv +1380 -0
  38. switch_trust/eval/__init__.py +0 -0
  39. switch_trust/eval/common/__init__.py +0 -0
  40. switch_trust/eval/common/converter_anthropic.py +172 -0
  41. switch_trust/eval/common/converter_genai.py +171 -0
  42. switch_trust/eval/common/converter_openai.py +198 -0
  43. switch_trust/eval/common/log.py +116 -0
  44. switch_trust/eval/common/reference.py +25 -0
  45. switch_trust/eval/common/schema.py +190 -0
  46. switch_trust/eval/common/utils.py +119 -0
  47. switch_trust/eval/core/__init__.py +0 -0
  48. switch_trust/eval/core/detectors/__init__.py +0 -0
  49. switch_trust/eval/core/detectors/detector.py +25 -0
  50. switch_trust/eval/core/detectors/detector_garak.py +112 -0
  51. switch_trust/eval/core/detectors/detector_model.py +123 -0
  52. switch_trust/eval/core/detectors/detector_model_adversarial.py +91 -0
  53. switch_trust/eval/core/detectors/detector_pii.py +67 -0
  54. switch_trust/eval/core/detectors/detector_secret.py +88 -0
  55. switch_trust/eval/core/detectors/detector_topic_guard.py +63 -0
  56. switch_trust/eval/core/detectors/detector_toxicity.py +78 -0
  57. switch_trust/eval/core/eval/__init__.py +0 -0
  58. switch_trust/eval/core/eval/eval_creator.py +166 -0
  59. switch_trust/eval/core/eval/evaluation.py +112 -0
  60. switch_trust/eval/core/eval/evaluation_adversarial.py +412 -0
  61. switch_trust/eval/core/eval/evaluation_garak_module.py +45 -0
  62. switch_trust/eval/core/eval/evaluation_garak_probe.py +308 -0
  63. switch_trust/eval/core/eval/evaluation_message_list.py +46 -0
  64. switch_trust/eval/core/eval/evaluation_multi.py +276 -0
  65. switch_trust/eval/core/eval/evaluation_single.py +89 -0
  66. switch_trust/eval/core/eval/evaluation_single_prompt.py +62 -0
  67. switch_trust/eval/core/eval/evaluation_topic_guard.py +305 -0
  68. switch_trust/eval/core/eval/metric_conciseness.py +179 -0
  69. switch_trust/eval/core/eval/metric_factual_accuracy.py +312 -0
  70. switch_trust/eval/core/eval/metric_instruction_adherence.py +177 -0
  71. switch_trust/eval/core/eval/metric_tone.py +180 -0
  72. switch_trust/eval/core/eval/metric_toxicity.py +146 -0
  73. switch_trust/eval/core/eval/observer.py +137 -0
  74. switch_trust/eval/core/message/__init__.py +0 -0
  75. switch_trust/eval/core/message/message_collection.py +37 -0
  76. switch_trust/eval/core/message/message_collection_csv.py +44 -0
  77. switch_trust/eval/core/message/message_collection_garak.py +46 -0
  78. switch_trust/eval/core/message/message_collection_memory.py +34 -0
  79. switch_trust/eval/core/models/__init__.py +0 -0
  80. switch_trust/eval/core/models/generator_model.py +421 -0
  81. switch_trust/eval/core/models/model.py +172 -0
  82. switch_trust/eval/core/models/model_adk.py +186 -0
  83. switch_trust/eval/core/models/model_anthropic.py +79 -0
  84. switch_trust/eval/core/models/model_anthropic_agent.py +104 -0
  85. switch_trust/eval/core/models/model_gemini.py +146 -0
  86. switch_trust/eval/core/models/model_generic_http.py +120 -0
  87. switch_trust/eval/core/models/model_http.py +135 -0
  88. switch_trust/eval/core/models/model_huggingface.py +75 -0
  89. switch_trust/eval/core/models/model_langserve.py +96 -0
  90. switch_trust/eval/core/models/model_litellm.py +52 -0
  91. switch_trust/eval/core/models/model_ollama.py +65 -0
  92. switch_trust/eval/core/models/model_openai.py +71 -0
  93. switch_trust/eval/core/models/model_openai_agent.py +92 -0
  94. switch_trust/eval/core/models/model_openai_compatible.py +66 -0
  95. switch_trust/eval/core/models/model_per_endpoint_limiter.py +80 -0
  96. switch_trust/eval/core/models/model_retry.py +204 -0
  97. switch_trust/eval/core/models/model_sync_wrapper.py +38 -0
  98. switch_trust/eval/core/models/model_vertex_agent_runtime.py +315 -0
  99. switch_trust/eval/core/models/response_schema.py +148 -0
  100. switch_trust/eval/core/optional_deps.py +57 -0
  101. switch_trust/eval/db/__init__.py +0 -0
  102. switch_trust/eval/db/base/__init__.py +0 -0
  103. switch_trust/eval/db/base/common_types.py +16 -0
  104. switch_trust/eval/db/base/detectors/__init__.py +0 -0
  105. switch_trust/eval/db/base/detectors/detector_helpers.py +88 -0
  106. switch_trust/eval/db/base/detectors/detector_repository.py +96 -0
  107. switch_trust/eval/db/base/detectors/detector_types.py +77 -0
  108. switch_trust/eval/db/base/eval/__init__.py +0 -0
  109. switch_trust/eval/db/base/eval/eval_helpers.py +186 -0
  110. switch_trust/eval/db/base/eval/eval_repository.py +120 -0
  111. switch_trust/eval/db/base/eval/eval_run.py +142 -0
  112. switch_trust/eval/db/base/eval/eval_types.py +127 -0
  113. switch_trust/eval/db/base/eval/model_eval_repository.py +79 -0
  114. switch_trust/eval/db/base/eval/model_eval_run_repository.py +72 -0
  115. switch_trust/eval/db/base/eval/model_eval_run_result_repository.py +42 -0
  116. switch_trust/eval/db/base/eval/model_eval_run_result_types.py +21 -0
  117. switch_trust/eval/db/base/eval/model_eval_run_types.py +78 -0
  118. switch_trust/eval/db/base/eval/model_eval_types.py +69 -0
  119. switch_trust/eval/db/base/message/__init__.py +0 -0
  120. switch_trust/eval/db/base/message/message_collection_helpers.py +50 -0
  121. switch_trust/eval/db/base/message/message_collection_repository.py +95 -0
  122. switch_trust/eval/db/base/message/message_collection_types.py +87 -0
  123. switch_trust/eval/db/base/models/__init__.py +0 -0
  124. switch_trust/eval/db/base/models/model_helpers.py +253 -0
  125. switch_trust/eval/db/base/models/model_repository.py +104 -0
  126. switch_trust/eval/db/base/models/model_types.py +159 -0
  127. switch_trust/eval/db/json/__init__.py +0 -0
  128. switch_trust/eval/db/json/repository_json.py +559 -0
  129. switch_trust/scan/__init__.py +12 -0
  130. switch_trust/scan/agent_scanner.py +812 -0
  131. switch_trust/scan/config/agent_opengrep_rules.yaml +533 -0
  132. switch_trust/scan/config/agent_taxonomy.json +517 -0
  133. switch_trust/scan/config/agentic_cvss_mapping.yaml +136 -0
  134. switch_trust/scan/config/compliance_mappings.json +110 -0
  135. switch_trust/scan/config/triage_prompt.txt +326 -0
  136. switch_trust/scan/constants.py +15 -0
  137. switch_trust/scan/exception_classification.py +179 -0
  138. switch_trust/scan/llm_provider.py +330 -0
  139. switch_trust/scan/opengrep_resolver.py +12 -0
  140. switch_trust/scan/reasoner.py +602 -0
  141. switch_trust/scan/schema.py +315 -0
  142. switch_trust/scan/scorer.py +372 -0
  143. switch_trust/scan/static_scanner.py +681 -0
  144. switch_trust/scan/taxonomy.py +121 -0
  145. switch_trust/scan/tool_dispatcher.py +773 -0
  146. switch_trust/scan/trace_logger.py +118 -0
  147. switch_trust/scan/trace_logger_file.py +143 -0
  148. switch_trust/scan/trace_logger_log.py +100 -0
  149. switch_trust/scan/triage.py +614 -0
  150. switch_trust/schema.py +79 -0
  151. switch_trust/secret_anonymizer.py +72 -0
  152. switch_trust_cli-1.7.0.dist-info/METADATA +495 -0
  153. switch_trust_cli-1.7.0.dist-info/RECORD +157 -0
  154. switch_trust_cli-1.7.0.dist-info/WHEEL +5 -0
  155. switch_trust_cli-1.7.0.dist-info/entry_points.txt +2 -0
  156. switch_trust_cli-1.7.0.dist-info/licenses/LICENSE +210 -0
  157. switch_trust_cli-1.7.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,72 @@
1
+ """Anonymize hardcoded secrets in source code text.
2
+
3
+ Replaces secret values with '*' characters of matching length, preserving
4
+ the surrounding code structure (variable names, quotes, line numbers).
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import re
10
+
11
+ _SECRET_KEYWORDS = (
12
+ r"API_?KEY|TOKEN|SECRET|PASSWORD|PASS|CREDENTIAL|DATABASE_URL|"
13
+ r"AUTH|PRIVATE_KEY|ACCESS_KEY|SECRET_KEY|CLIENT_SECRET"
14
+ )
15
+
16
+ _SECRET_ASSIGNMENT_RE = re.compile(
17
+ r"(\b\w*(?:" + _SECRET_KEYWORDS + r")\w*" # variable name containing a keyword
18
+ r"""\s*=\s*)(["'])""" # = and opening quote
19
+ r"(.+?)" # the secret value (non-greedy)
20
+ r"(\2)", # matching closing quote
21
+ re.IGNORECASE,
22
+ )
23
+
24
+ _STANDALONE_SECRET_RE = re.compile(
25
+ r"(?<=[\"' =])" # preceded by quote, space, or equals
26
+ r"("
27
+ r"sk-[A-Za-z0-9\-_]{10,}"
28
+ r"|AIza[A-Za-z0-9_\-]{35,}"
29
+ r"|key-[A-Za-z0-9]{10,}"
30
+ r"|pat-[A-Za-z0-9]{10,}"
31
+ r"|ghp_[A-Za-z0-9]{30,}"
32
+ r"|gho_[A-Za-z0-9]{30,}"
33
+ r"|glpat-[A-Za-z0-9\-_]{20,}"
34
+ r"|xox[bpras]-[A-Za-z0-9\-]{10,}"
35
+ r")",
36
+ re.IGNORECASE,
37
+ )
38
+
39
+ _BEARER_RE = re.compile(
40
+ r"(Bearer\s+)([A-Za-z0-9\-_.~+/]+=*)",
41
+ re.IGNORECASE,
42
+ )
43
+
44
+
45
+ def _mask_assignment(m: re.Match) -> str:
46
+ prefix = m.group(1) # e.g. 'API_KEY = '
47
+ quote = m.group(2) # " or '
48
+ value = m.group(3) # the secret
49
+ return prefix + quote + "*" * len(value) + quote
50
+
51
+
52
+ def _mask_standalone(m: re.Match) -> str:
53
+ return "*" * len(m.group(1))
54
+
55
+
56
+ def _mask_bearer(m: re.Match) -> str:
57
+ return m.group(1) + "*" * len(m.group(2))
58
+
59
+
60
+ def anonymize_secrets(text: str) -> str:
61
+ """Replace hardcoded secret values with '*' characters of matching length.
62
+
63
+ Applies two strategies:
64
+ 1. Assignment-based: VAR_NAME = "secret" where the variable name contains
65
+ keywords like KEY, TOKEN, SECRET, PASSWORD, etc.
66
+ 2. Standalone tokens: Known secret prefixes (sk-*, AIza*, key-*, pat-*, etc.)
67
+ appearing in any context.
68
+ """
69
+ result = _SECRET_ASSIGNMENT_RE.sub(_mask_assignment, text)
70
+ result = _STANDALONE_SECRET_RE.sub(_mask_standalone, result)
71
+ result = _BEARER_RE.sub(_mask_bearer, result)
72
+ return result
@@ -0,0 +1,495 @@
1
+ Metadata-Version: 2.4
2
+ Name: switch-trust-cli
3
+ Version: 1.7.0
4
+ Summary: Command-line tool for evaluating agents, offering two features to assess agents via code scanning (`switch-trust scan`, whitebox testing) and runtime evaluation (`switch-trust eval`, blackbox testing)
5
+ Author-email: SandboxAQ <info@switchagents.ai>
6
+ License: Software: Switch Trust
7
+
8
+ Copyright (c) 2026 SB Technology, Inc. dba SandboxAQ
9
+
10
+ This software is licensed to you under the Apache 2.0 License as limited by
11
+ the "Commons Clause" license condition below. The "Commons Clause" license
12
+ condition has been modified from the original version to clarify that the
13
+ "Common Clause" license condition also applies to any derivatives of the
14
+ Software.
15
+
16
+
17
+ "Commons Clause" License Condition v1.0, as modified below
18
+
19
+ The Software is provided to you by the Licensor under the License, as defined
20
+ below, subject to the following condition.
21
+
22
+ Without limiting other conditions in the License, the grant of rights under the
23
+ License will not include, and the License does not grant to you, the right to
24
+ Sell the Software or any derivative of the Software.
25
+
26
+ For purposes of the foregoing, "Sell" means practicing any or all of the rights
27
+ granted to you under the License to provide to third parties, for a fee or
28
+ other consideration (including without limitation fees for hosting or
29
+ consulting/ support services related to the Software), a product or service
30
+ whose value derives, entirely or substantially, from the functionality of the
31
+ Software. Any license notice or attribution required by the License must also
32
+ include this Commons Clause License Condition notice.
33
+
34
+
35
+ Apache License Version 2.0, January 2004
36
+ http://www.apache.org/licenses/
37
+
38
+
39
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
40
+
41
+ 1. Definitions.
42
+
43
+ "License" shall mean the terms and conditions for use, reproduction, and
44
+ distribution as defined by Sections 1 through 9 of this document.
45
+
46
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright
47
+ owner that is granting the License.
48
+
49
+ "Legal Entity" shall mean the union of the acting entity and all other entities
50
+ that control, are controlled by, or are under common control with that entity.
51
+ For the purposes of this definition, "control" means (i) the power, direct or
52
+ indirect, to cause the direction or management of such entity, whether by
53
+ contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
54
+ outstanding shares, or (iii) beneficial ownership of such entity.
55
+
56
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
57
+ permissions granted by this License.
58
+
59
+ "Source" form shall mean the preferred form for making modifications, including
60
+ but not limited to software source code, documentation source, and
61
+ configuration files.
62
+
63
+ "Object" form shall mean any form resulting from mechanical transformation or
64
+ translation of a Source form, including but not limited to compiled object code,
65
+ generated documentation, and conversions to other media types.
66
+
67
+ "Work" shall mean the work of authorship, whether in Source or Object form, made
68
+ available under the License, as indicated by a copyright notice that is included
69
+ in or attached to the work.
70
+
71
+ "Derivative Works" shall mean any work, whether in Source or Object form, that
72
+ is based on (or derived from) the Work and for which the editorial revisions,
73
+ annotations, elaborations, or other modifications represent, as a whole, an
74
+ original work of authorship. For the purposes of this License, Derivative Works
75
+ shall not include works that remain separable from, or merely link (or bind by
76
+ name) to the interfaces of, the Work and Derivative Works thereof.
77
+
78
+ "Contribution" shall mean any work of authorship, including the original version
79
+ of the Work and any modifications or additions thereto, that is intentionally
80
+ submitted to Licensor for inclusion in the Work by the copyright owner or by an
81
+ individual or Legal Entity authorized to submit on behalf of the copyright
82
+ owner. For the purposes of this definition, "submitted" means any form of
83
+ electronic, verbal, or written communication sent to the Licensor or its
84
+ representatives, including but not limited to communication on electronic
85
+ mailing lists, source code control systems, and issue tracking systems that are
86
+ managed by, or on behalf of, the Licensor for the purpose of discussing and
87
+ improving the Work, but excluding communication that is conspicuously marked or
88
+ otherwise designated in writing by the copyright owner as "Not a Contribution."
89
+
90
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
91
+ of whom a Contribution has been received by Licensor and subsequently
92
+ incorporated within the Work.
93
+
94
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
95
+ License, each Contributor hereby grants to You a perpetual, worldwide,
96
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
97
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
98
+ sublicense, and distribute the Work and such Derivative Works in Source or
99
+ Object form.
100
+
101
+ 3. Grant of Patent License. Subject to the terms and conditions of this
102
+ License, each Contributor hereby grants to You a perpetual, worldwide,
103
+ non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
104
+ section) patent license to make, have made, use, offer to sell, sell, import,
105
+ and otherwise transfer the Work, where such license applies only to those patent
106
+ claims licensable by such Contributor that are necessarily infringed by their
107
+ Contribution(s) alone or by combination of their Contribution(s) with the Work
108
+ to which such Contribution(s) was submitted. If You institute patent litigation
109
+ against any entity (including a cross-claim or counterclaim in a lawsuit)
110
+ alleging that the Work or a Contribution incorporated within the Work
111
+ constitutes direct or contributory patent infringement, then any patent licenses
112
+ granted to You under this License for that Work shall terminate as of the date
113
+ such litigation is filed.
114
+
115
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
116
+ Derivative Works thereof in any medium, with or without modifications, and in
117
+ Source or Object form, provided that You meet the following conditions:
118
+
119
+ (a) You must give any other recipients of the Work or Derivative Works a copy
120
+ of this License; and
121
+
122
+ (b) You must cause any modified files to carry prominent notices stating that
123
+ You changed the files; and
124
+
125
+ (c) You must retain, in the Source form of any Derivative Works that You
126
+ distribute, all copyright, patent, trademark, and attribution notices from the
127
+ Source form of the Work, excluding those notices that do not pertain to any part
128
+ of the Derivative Works; and
129
+
130
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then
131
+ any Derivative Works that You distribute must include a readable copy of the
132
+ attribution notices contained within such NOTICE file, excluding those notices
133
+ that do not pertain to any part of the Derivative Works, in at least one of the
134
+ following places: within a NOTICE text file distributed as part of the
135
+ Derivative Works; within the Source form or documentation, if provided along
136
+ with the Derivative Works; or, within a display generated by the Derivative
137
+ Works, if and wherever such third-party notices normally appear. The contents of
138
+ the NOTICE file are for informational purposes only and do not modify the
139
+ License. You may add Your own attribution notices within Derivative Works that
140
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
141
+ provided that such additional attribution notices cannot be construed as
142
+ modifying the License. You may add Your own copyright statement to Your
143
+ modifications and may provide additional or different license terms and
144
+ conditions for use, reproduction, or distribution of Your modifications, or for
145
+ any such Derivative Works as a whole, provided Your use, reproduction, and
146
+ distribution of the Work otherwise complies with the conditions stated in this
147
+ License.
148
+
149
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
150
+ Contribution intentionally submitted for inclusion in the Work by You to the
151
+ Licensor shall be under the terms and conditions of this License, without any
152
+ additional terms or conditions. Notwithstanding the above, nothing herein shall
153
+ supersede or modify the terms of any separate license agreement you may have
154
+ executed with Licensor regarding such Contributions.
155
+
156
+ 6. Trademarks. This License does not grant permission to use the trade names,
157
+ trademarks, service marks, or product names of the Licensor, except as required
158
+ for reasonable and customary use in describing the origin of the Work and
159
+ reproducing the content of the NOTICE file.
160
+
161
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
162
+ writing, Licensor provides the Work (and each Contributor provides its
163
+ Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
164
+ KIND, either express or implied, including, without limitation, any warranties
165
+ or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
166
+ PARTICULAR PURPOSE. You are solely responsible for determining the
167
+ appropriateness of using or redistributing the Work and assume any risks
168
+ associated with Your exercise of permissions under this License.
169
+
170
+ 8. Limitation of Liability. In no event and under no legal theory, whether in
171
+ tort (including negligence), contract, or otherwise, unless required by
172
+ applicable law (such as deliberate and grossly negligent acts) or agreed to in
173
+ writing, shall any Contributor be liable to You for damages, including any
174
+ direct, indirect, special, incidental, or consequential damages of any character
175
+ arising as a result of this License or out of the use or inability to use the
176
+ Work (including but not limited to damages for loss of goodwill, work stoppage,
177
+ computer failure or malfunction, or any and all other commercial damages or
178
+ losses), even if such Contributor has been advised of the possibility of such
179
+ damages.
180
+
181
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or
182
+ Derivative Works thereof, You may choose to offer, and charge a fee for,
183
+ acceptance of support, warranty, indemnity, or other liability obligations
184
+ and/or rights consistent with this License. However, in accepting such
185
+ obligations, You may act only on Your own behalf and on Your sole
186
+ responsibility, not on behalf of any other Contributor, and only if You agree to
187
+ indemnify, defend, and hold each Contributor harmless for any liability incurred
188
+ by, or claims asserted against, such Contributor by reason of your accepting any
189
+ such warranty or additional liability.
190
+
191
+ END OF TERMS AND CONDITIONS
192
+
193
+
194
+ APPENDIX: How to apply the Apache License to your work
195
+
196
+ To apply the Apache License to your work, attach the following boilerplate
197
+ notice, with the fields enclosed by brackets "[]" replaced with your own
198
+ identifying information. (Don't include the brackets!) The text should be
199
+ enclosed in the appropriate comment syntax for the file format. We also
200
+ recommend that a file or class name and description of purpose be included on
201
+ the same "printed page" as the copyright notice for easier identification
202
+ within third-party archives.
203
+
204
+ Copyright [yyyy] [name of copyright owner]
205
+
206
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
207
+ this file except in compliance with the License. You may obtain a copy of the
208
+ License at
209
+
210
+ http://www.apache.org/licenses/LICENSE-2.0
211
+
212
+ Unless required by applicable law or agreed to in writing, software distributed
213
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
214
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
215
+ specific language governing permissions and limitations under the License.
216
+
217
+ Project-URL: Homepage, https://github.com/sandbox-quantum/switch-trust
218
+ Project-URL: Issues, https://github.com/sandbox-quantum/switch-trust/issues
219
+ Requires-Python: >=3.11
220
+ Description-Content-Type: text/markdown
221
+ License-File: LICENSE
222
+ Requires-Dist: aiohttp>=3.14.3
223
+ Requires-Dist: anthropic==0.87.0
224
+ Requires-Dist: pyOpenSSL>=26.4.0
225
+ Requires-Dist: cryptography>=50.0.0
226
+ Requires-Dist: bandit==1.9.4
227
+ Requires-Dist: cvss>=2.6
228
+ Requires-Dist: datafog>=4.4.0
229
+ Requires-Dist: dataclasses-json==0.6.7
230
+ Requires-Dist: detect-secrets==1.5.0
231
+ Requires-Dist: google-adk==2.2.0
232
+ Requires-Dist: litellm>=1.83.7
233
+ Requires-Dist: openai==2.29.0
234
+ Requires-Dist: opentelemetry-api<=1.41.1,>=1.38.0
235
+ Requires-Dist: opentelemetry-exporter-otlp-proto-http<=1.41.1,>=1.38.0
236
+ Requires-Dist: opentelemetry-sdk<=1.41.1,>=1.38.0
237
+ Requires-Dist: pip-audit==2.10.1
238
+ Requires-Dist: protobuf<7,>=6.33.5
239
+ Requires-Dist: pydantic==2.12.5
240
+ Requires-Dist: python-dotenv==1.2.2
241
+ Requires-Dist: requests>=2.33.0
242
+ Requires-Dist: rich>=13.0
243
+ Requires-Dist: msgpack>=1.2.1
244
+ Requires-Dist: pydantic-settings>=2.14.2
245
+ Provides-Extra: full
246
+ Requires-Dist: garak==0.14.0; extra == "full"
247
+ Requires-Dist: transformers[torch]==5.10.1; extra == "full"
248
+ Dynamic: license-file
249
+
250
+ <div align="center">
251
+
252
+ <picture>
253
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/sandbox-quantum/switch-trust-cli/main/images/switch-trust-dark.png">
254
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/sandbox-quantum/switch-trust-cli/main/images/switch-trust-light.png">
255
+ <img src="https://raw.githubusercontent.com/sandbox-quantum/switch-trust-cli/main/images/switch-trust-light.png" alt="Switch Trust" width="450">
256
+ </picture>
257
+
258
+ [![PyPI version](https://img.shields.io/pypi/v/switch-trust-cli?color=A1C9D2&logo=pypi&logoColor=white)](https://pypi.org/project/switch-trust-cli/) [![Python](https://img.shields.io/badge/python-3.11+-A1C9D2?logo=python&logoColor=white)](https://www.python.org/downloads/) [![Documentation](https://img.shields.io/badge/docs-docs.switchagents.ai-FF895E)](https://docs.switchagents.ai) [![Website](https://img.shields.io/badge/website-switchagents.ai-FF895E)](https://switchagents.ai)
259
+
260
+ </div>
261
+
262
+ **Ship AI agents with confidence**
263
+
264
+ > [!IMPORTANT]
265
+ > **Flint AI is now Switch Trust.**
266
+
267
+ One CLI to analyze agent code and runtime behavior, any framework.
268
+
269
+ | | **Switch Trust Scan** | **Switch Trust Eval** |
270
+ |---|---|---|
271
+ | **Command** | `switch-trust scan` | `switch-trust eval` |
272
+ | **What** | AI-powered security analysis of your agent's code (whitebox testing) | Runtime behavioral evaluation with adversarial prompts (blackbox testing) |
273
+ | **Output** | Security findings mapped to OWASP top 10 with CVSS severity scores | Evaluation scores (0-100%) mapped to OWASP top 10 |
274
+
275
+ **Why Switch Trust?**
276
+ - **AI-powered analysis** — Contextual code understanding, not just pattern matching
277
+ - **OWASP ASI mapped** — Findings aligned to Top 10 for Agentic Applications
278
+ - **100% free** — First results in minutes
279
+
280
+
281
+ ## Try it now - 5 minute Quickstart
282
+
283
+ > **Requirements**
284
+ > - Python 3.11 or later
285
+ > - [OpenGrep](https://github.com/opengrep/opengrep#linux--macos) (required for Switch Trust Scan)
286
+ > - A running agent accessible via HTTP (required for Switch Trust Eval)
287
+ >
288
+ > **Supported frameworks:** Google ADK, Google GenAI, Anthropic, OpenAI, OpenAI Agents SDK, LangGraph, CrewAI, AutoGen, HuggingFace Transformers, HuggingFace smolagents
289
+
290
+ ### Step 1: Install Switch Trust
291
+
292
+ Using a virtual environment is recommended to avoid dependency conflicts:
293
+ ```bash
294
+ python3 -m venv .venv
295
+ source .venv/bin/activate
296
+ ```
297
+
298
+ Install Switch Trust CLI:
299
+ ```bash
300
+ pip install switch-trust-cli
301
+ ```
302
+
303
+ <details>
304
+ <summary>Optional <code>full</code> extra for toxicity, local & garak evaluations</summary>
305
+
306
+ Some evaluations rely on heavy ML backends that are kept out of the default
307
+ install: toxicity detection, local evaluation of models retrieved from Huggingface,
308
+ and garak probes and detectors. Install them with the optional `full`
309
+ extra when you need those features:
310
+ ```bash
311
+ pip install "switch-trust-cli[full]"
312
+ ```
313
+ </details>
314
+
315
+ ### Step 2: Configure your LLM provider
316
+
317
+ Switch Trust uses AI to analyze agent code and score reliability. Run the interactive setup:
318
+
319
+ ```bash
320
+ switch-trust init
321
+ ```
322
+
323
+ You'll be prompted to select a provider (Gemini, OpenAI, Anthropic, or LiteLLM), choose a model, and enter your API key.
324
+
325
+ <details>
326
+ <summary>Where to get API keys</summary>
327
+
328
+ - **Google Gemini**: [aistudio.google.com/apikey](https://aistudio.google.com/apikey) (free tier available)
329
+ - **OpenAI**: [platform.openai.com/api-keys](https://platform.openai.com/api-keys)
330
+ - **Anthropic**: [console.anthropic.com/settings/keys](https://console.anthropic.com/settings/keys)
331
+ - **LiteLLM**: Supports 100+ providers. See [docs.litellm.ai](https://docs.litellm.ai/docs/)
332
+
333
+ </details>
334
+
335
+ > Run into issues? See [installation troubleshooting](https://docs.switchagents.ai/switch-trust-cli/troubleshooting/common-issues#installation)
336
+
337
+ ### Step 3: Try the example agents
338
+
339
+ To demonstrate the CLIs capabilities, we've shipped this tool with two example agents. You can get them [here](https://github.com/sandbox-quantum/switch-trust/tree/main/examples).
340
+
341
+ **Both agents work with both `switch-trust scan` and `switch-trust eval`**:
342
+
343
+ | Agent | Framework | Description |
344
+ |-------|-----------|-------------|
345
+ | **weather_agent** | Google ADK | Weather assistant that looks up conditions for cities. Should refuse off-topic requests. |
346
+ | **bookstore_agent** | OpenAI Agents SDK | Customer support assistant for an online bookstore. Searches books, checks orders, and processes returns. |
347
+
348
+ The included `examples/config.json` has both agents configured with builtin evaluations (OWASP LLM01–LLM09, PII, secrets) and custom tests.
349
+
350
+ ---
351
+
352
+ `switch-trust scan` finds security issues in the code without running the agent. We'll scan the bookstore agent to see what issues Switch Trust can find:
353
+ ```bash
354
+ switch-trust scan examples/bookstore_agent/
355
+ ```
356
+
357
+ <img src="https://raw.githubusercontent.com/sandbox-quantum/switch-trust/main/images/scan-findings.png" alt="Scan results showing security findings" width="550">
358
+
359
+ *Example: Scan found 2 security issues - High severity missing authentication and Medium severity unbounded execution loop*
360
+
361
+ ---
362
+
363
+ `switch-trust eval` tests runtime behavior, so the agent needs to be running. Start the bookstore agent:
364
+
365
+ ```bash
366
+ # Start the bookstore agent (serves on http://localhost:8010)
367
+ uvx --with openai-agents,fastapi --from uvicorn uvicorn examples.bookstore_agent.agent:app --port 8010 --host 0.0.0.0
368
+ ```
369
+
370
+ In a new terminal, run evaluations:
371
+
372
+ ```bash
373
+ switch-trust eval run --model model-bookstore-agent --config examples/config.json
374
+ ```
375
+
376
+ ### Step 4: Test your own agents
377
+
378
+ See our documentation to configure, scan and evaluate your agents:
379
+ - `switch-trust scan`
380
+ - [Scan your own agent](https://docs.switchagents.ai/switch-trust-cli/scan/getting-started) — Apply Switch Trust Scan to your codebase
381
+ - [Understand scan results](https://docs.switchagents.ai/switch-trust-cli/scan/scan-results) — Interpret findings and severity scores
382
+ - `switch-trust eval`
383
+ - [Evaluate your own agent](https://docs.switchagents.ai/switch-trust-cli/eval/getting-started) — Configure and test your agent's behavior
384
+ - [Configuration](https://docs.switchagents.ai/switch-trust-cli/eval/eval-configuration) — In-depth documentation of our configuration
385
+ - [Understand eval results](https://docs.switchagents.ai/switch-trust-cli/eval/eval-results) — What the scores means and how to improve
386
+
387
+ **Ship with confidence.** Validate behavior, catch risks, prove readiness.
388
+
389
+
390
+ ## Commands
391
+
392
+ ### `init`
393
+
394
+ Setup wizard that configures Switch Trust for first use. Creates the `~/.switch-trust` directory with a `.env` file (LLM provider, API key, runtime settings) and a `config.json` skeleton.
395
+
396
+ Runs automatically on first use in non-CI environments. You can re-run it at any time to reconfigure.
397
+
398
+ ```bash
399
+ switch-trust init
400
+ ```
401
+
402
+ ### `scan`
403
+
404
+ AI-powered security analysis of agent source code. Finds vulnerabilities, misconfigurations, and OWASP Top 10 violations.
405
+
406
+ ```bash
407
+ # Scan a directory
408
+ switch-trust scan /path/to/agent/code
409
+
410
+ # Scan a single file
411
+ switch-trust scan agent.py
412
+
413
+ # Specify output file
414
+ switch-trust scan /path/to/code --output results.json
415
+ ```
416
+
417
+ [Full scan guide](https://docs.switchagents.ai/switch-trust-cli/scan/getting-started)
418
+
419
+ ### `eval`
420
+
421
+ Test agent behavior at runtime. Get a evaluation score proving production-readiness.
422
+
423
+ ```bash
424
+ # List all available configuration
425
+ switch-trust eval evaluations list
426
+
427
+ # List your agents and models
428
+ switch-trust eval models list
429
+
430
+ # Attach an evalation to your agent
431
+ switch-trust eval model-evaluations attach \
432
+ --model my-agent \
433
+ --eval eval-llm01-adversarial
434
+
435
+ # Run all evaluations for an agent
436
+ switch-trust eval run --model my-agent
437
+ ```
438
+
439
+ The `switch-trust eval` command requires configuration. See [Configuration](https://docs.switchagents.ai/switch-trust-cli/eval/eval-configuration) to:
440
+ 1. Define your models (agents to test)
441
+ 2. View available evaluations
442
+ 3. Attach evaluations to models
443
+
444
+ [Full eval guide](https://docs.switchagents.ai/switch-trust-cli/eval/getting-started)
445
+
446
+ ## Documentation
447
+
448
+ **Complete guides and reference:**
449
+ - [Getting started](https://docs.switchagents.ai)
450
+ - [Command reference](https://docs.switchagents.ai/switch-trust-cli/reference/commands)
451
+ - [Configuration](https://docs.switchagents.ai/switch-trust-cli/eval/eval-configuration)
452
+ - [Environment variables](https://docs.switchagents.ai/switch-trust-cli/reference/env-vars)
453
+ - [Built-in evaluations](https://docs.switchagents.ai/switch-trust-cli/reference/builtin-evaluations)
454
+ - [Data privacy](https://docs.switchagents.ai/switch-trust-cli/reference/data-privacy)
455
+ - [FAQ](https://docs.switchagents.ai/switch-trust-cli/resources/faq)
456
+
457
+ ## Data privacy
458
+
459
+ Switch Trust runs on your machine, but several features can call external LLM providers. This can be configured via `GENERATOR_MODEL`
460
+ (located in `~/.switch-trust/.env`, created by `switch-trust init`). You can set this to a remote managed LLM (i.e. `gemini`, `openai`, `anthropic`)
461
+ or a locally hosted LLM (i.e. `litellm` or `ollama`).
462
+
463
+ [Read more](https://docs.switchagents.ai/switch-trust-cli/reference/data-privacy).
464
+
465
+ ### Telemetry
466
+
467
+ Switch Trust CLI collects **anonymous usage analytics** to help us understand how the tool is used and improve it. Telemetry is **opt-in** — you are asked for consent during `switch-trust init`, and no data is sent without your explicit agreement.
468
+
469
+ **What we collect:**
470
+
471
+ | Data | Example | Purpose |
472
+ |------|---------|---------|
473
+ | Command name | `scan`, `eval run` | Understand which features are used |
474
+ | CLI version | `1.1.1` | Track adoption of new releases |
475
+ | Execution duration | `12.3s` | Identify performance issues |
476
+ | Error type (on crash) | `ConnectionError` | Prioritize bug fixes |
477
+ | CI environment flag | `true` / `false` | Understand CI vs interactive usage |
478
+ | Anonymous client ID | `a1b2c3d4-...` (random UUID) | Count unique installations |
479
+
480
+ **What we never collect:** source code, file paths, prompts, API keys, model outputs, usernames, hostnames, IP addresses, or any personally identifiable information.
481
+
482
+ **Opting out:** Set `SWITCH_TRUST_TELEMETRY_CONSENT=false` in `~/.switch-trust/.env`, or select "N" when prompted during `switch-trust init`. You can change this at any time.
483
+
484
+ ## Contributing
485
+
486
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
487
+
488
+ ## License
489
+
490
+ Free to use - [full license](LICENSE).
491
+
492
+ ## Contact
493
+
494
+ - Website: [https://switchagents.ai](https://switchagents.ai)
495
+ - Email: [info@switchagents.ai](mailto:info@switchagents.ai)