agentsecure 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.
- agentsecure-0.1.0/LICENSE +68 -0
- agentsecure-0.1.0/NOTICE +4 -0
- agentsecure-0.1.0/PKG-INFO +181 -0
- agentsecure-0.1.0/README.md +154 -0
- agentsecure-0.1.0/agentsecure/__init__.py +4 -0
- agentsecure-0.1.0/agentsecure/__main__.py +5 -0
- agentsecure-0.1.0/agentsecure/api/__init__.py +1 -0
- agentsecure-0.1.0/agentsecure/api/server.py +8 -0
- agentsecure-0.1.0/agentsecure/api/services.py +3 -0
- agentsecure-0.1.0/agentsecure/cli/__init__.py +2 -0
- agentsecure-0.1.0/agentsecure/cli/common.py +116 -0
- agentsecure-0.1.0/agentsecure/cli/demo.py +97 -0
- agentsecure-0.1.0/agentsecure/cli/main.py +912 -0
- agentsecure-0.1.0/agentsecure/cli/policy.py +47 -0
- agentsecure-0.1.0/agentsecure/cli/project.py +137 -0
- agentsecure-0.1.0/agentsecure/cli/secrets.py +293 -0
- agentsecure-0.1.0/agentsecure/cli/settings.py +112 -0
- agentsecure-0.1.0/agentsecure/client/__init__.py +1 -0
- agentsecure-0.1.0/agentsecure/client/wrappers.py +87 -0
- agentsecure-0.1.0/agentsecure/cloud.py +30 -0
- agentsecure-0.1.0/agentsecure/core/__init__.py +2 -0
- agentsecure-0.1.0/agentsecure/core/capabilities.py +109 -0
- agentsecure-0.1.0/agentsecure/core/command_metadata.py +13 -0
- agentsecure-0.1.0/agentsecure/core/config.py +173 -0
- agentsecure-0.1.0/agentsecure/core/config_profiles.py +192 -0
- agentsecure-0.1.0/agentsecure/core/container.py +75 -0
- agentsecure-0.1.0/agentsecure/core/key_service.py +140 -0
- agentsecure-0.1.0/agentsecure/core/models.py +183 -0
- agentsecure-0.1.0/agentsecure/core/policy_mutation.py +127 -0
- agentsecure-0.1.0/agentsecure/core/policy_ports.py +61 -0
- agentsecure-0.1.0/agentsecure/core/policy_response.py +68 -0
- agentsecure-0.1.0/agentsecure/core/policy_validation.py +97 -0
- agentsecure-0.1.0/agentsecure/core/product.py +267 -0
- agentsecure-0.1.0/agentsecure/core/time.py +38 -0
- agentsecure-0.1.0/agentsecure/crypto/__init__.py +2 -0
- agentsecure-0.1.0/agentsecure/crypto/cipher.py +57 -0
- agentsecure-0.1.0/agentsecure/crypto/key_provider.py +39 -0
- agentsecure-0.1.0/agentsecure/daemon/__init__.py +1 -0
- agentsecure-0.1.0/agentsecure/daemon/commands.py +8 -0
- agentsecure-0.1.0/agentsecure/daemon/policies.py +3 -0
- agentsecure-0.1.0/agentsecure/daemon/sessions.py +3 -0
- agentsecure-0.1.0/agentsecure/daemon/supervisor.py +3 -0
- agentsecure-0.1.0/agentsecure/discovery/__init__.py +2 -0
- agentsecure-0.1.0/agentsecure/discovery/dotenv_scanner.py +60 -0
- agentsecure-0.1.0/agentsecure/discovery/env_scanner.py +29 -0
- agentsecure-0.1.0/agentsecure/discovery/patterns.py +90 -0
- agentsecure-0.1.0/agentsecure/discovery/scanner.py +27 -0
- agentsecure-0.1.0/agentsecure/discovery/suggestions.py +154 -0
- agentsecure-0.1.0/agentsecure/gateway/__init__.py +2 -0
- agentsecure-0.1.0/agentsecure/gateway/proxy.py +272 -0
- agentsecure-0.1.0/agentsecure/guard/__init__.py +2 -0
- agentsecure-0.1.0/agentsecure/guard/command.py +62 -0
- agentsecure-0.1.0/agentsecure/guard/network.py +92 -0
- agentsecure-0.1.0/agentsecure/guard/sanitizer.py +105 -0
- agentsecure-0.1.0/agentsecure/guard/wrappers.py +50 -0
- agentsecure-0.1.0/agentsecure/implementations/__init__.py +2 -0
- agentsecure-0.1.0/agentsecure/implementations/audit.py +53 -0
- agentsecure-0.1.0/agentsecure/implementations/encrypted_secret_store.py +73 -0
- agentsecure-0.1.0/agentsecure/implementations/grant_store.py +84 -0
- agentsecure-0.1.0/agentsecure/implementations/local_secret_store.py +53 -0
- agentsecure-0.1.0/agentsecure/implementations/policy.py +126 -0
- agentsecure-0.1.0/agentsecure/implementations/secret_store_factory.py +21 -0
- agentsecure-0.1.0/agentsecure/implementations/secrets.py +138 -0
- agentsecure-0.1.0/agentsecure/interfaces/__init__.py +2 -0
- agentsecure-0.1.0/agentsecure/interfaces/audit.py +11 -0
- agentsecure-0.1.0/agentsecure/interfaces/grants.py +23 -0
- agentsecure-0.1.0/agentsecure/interfaces/key_store.py +15 -0
- agentsecure-0.1.0/agentsecure/interfaces/policy.py +24 -0
- agentsecure-0.1.0/agentsecure/interfaces/secrets.py +19 -0
- agentsecure-0.1.0/agentsecure/workspace/__init__.py +2 -0
- agentsecure-0.1.0/agentsecure/workspace/apply.py +141 -0
- agentsecure-0.1.0/agentsecure/workspace/diff.py +104 -0
- agentsecure-0.1.0/agentsecure/workspace/materializer.py +112 -0
- agentsecure-0.1.0/agentsecure/workspace/rewriter.py +54 -0
- agentsecure-0.1.0/agentsecure/workspace/strategies.py +140 -0
- agentsecure-0.1.0/agentsecure.egg-info/PKG-INFO +181 -0
- agentsecure-0.1.0/agentsecure.egg-info/SOURCES.txt +104 -0
- agentsecure-0.1.0/agentsecure.egg-info/dependency_links.txt +1 -0
- agentsecure-0.1.0/agentsecure.egg-info/entry_points.txt +2 -0
- agentsecure-0.1.0/agentsecure.egg-info/requires.txt +3 -0
- agentsecure-0.1.0/agentsecure.egg-info/top_level.txt +1 -0
- agentsecure-0.1.0/pyproject.toml +4 -0
- agentsecure-0.1.0/setup.cfg +39 -0
- agentsecure-0.1.0/setup.py +5 -0
- agentsecure-0.1.0/tests/test_audit.py +38 -0
- agentsecure-0.1.0/tests/test_cli.py +92 -0
- agentsecure-0.1.0/tests/test_cli_demo.py +22 -0
- agentsecure-0.1.0/tests/test_cli_policy.py +57 -0
- agentsecure-0.1.0/tests/test_diff.py +56 -0
- agentsecure-0.1.0/tests/test_discovery.py +52 -0
- agentsecure-0.1.0/tests/test_encrypted_secret_store.py +33 -0
- agentsecure-0.1.0/tests/test_env_policy.py +329 -0
- agentsecure-0.1.0/tests/test_env_policy_contract.py +401 -0
- agentsecure-0.1.0/tests/test_gateway_credentials.py +34 -0
- agentsecure-0.1.0/tests/test_guard.py +92 -0
- agentsecure-0.1.0/tests/test_guard_network.py +76 -0
- agentsecure-0.1.0/tests/test_key_service.py +62 -0
- agentsecure-0.1.0/tests/test_policy.py +77 -0
- agentsecure-0.1.0/tests/test_policy_mutation.py +204 -0
- agentsecure-0.1.0/tests/test_product.py +91 -0
- agentsecure-0.1.0/tests/test_secret_scan.py +30 -0
- agentsecure-0.1.0/tests/test_secrets.py +98 -0
- agentsecure-0.1.0/tests/test_workspace.py +165 -0
- agentsecure-0.1.0/tests/test_workspace_apply.py +81 -0
- agentsecure-0.1.0/tests/test_wrappers.py +43 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
10
|
+
|
|
11
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
12
|
+
|
|
13
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or ownership of fifty percent (50%) or more of the outstanding shares, or beneficial ownership of such entity.
|
|
14
|
+
|
|
15
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
16
|
+
|
|
17
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
18
|
+
|
|
19
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
20
|
+
|
|
21
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work.
|
|
22
|
+
|
|
23
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on or derived from the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link or bind by name to the interfaces of, the Work and Derivative Works thereof.
|
|
24
|
+
|
|
25
|
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
26
|
+
|
|
27
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
28
|
+
|
|
29
|
+
2. Grant of Copyright License.
|
|
30
|
+
|
|
31
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
32
|
+
|
|
33
|
+
3. Grant of Patent License.
|
|
34
|
+
|
|
35
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution alone or by combination of their Contribution with the Work to which such Contribution was submitted. If You institute patent litigation against any entity alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
36
|
+
|
|
37
|
+
4. Redistribution.
|
|
38
|
+
|
|
39
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
40
|
+
|
|
41
|
+
You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
42
|
+
You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
43
|
+
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
44
|
+
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or within a display generated by the Derivative Works, if and wherever such third-party notices normally appear.
|
|
45
|
+
|
|
46
|
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
47
|
+
|
|
48
|
+
5. Submission of Contributions.
|
|
49
|
+
|
|
50
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions.
|
|
51
|
+
|
|
52
|
+
6. Trademarks.
|
|
53
|
+
|
|
54
|
+
This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
55
|
+
|
|
56
|
+
7. Disclaimer of Warranty.
|
|
57
|
+
|
|
58
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the Work on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
|
|
59
|
+
|
|
60
|
+
8. Limitation of Liability.
|
|
61
|
+
|
|
62
|
+
In no event and under no legal theory, whether in tort, contract, or otherwise, unless required by applicable law or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages arising as a result of this License or out of the use or inability to use the Work, even if such Contributor has been advised of the possibility of such damages.
|
|
63
|
+
|
|
64
|
+
9. Accepting Warranty or Additional Liability.
|
|
65
|
+
|
|
66
|
+
While redistributing the Work or Derivative Works thereof, You may choose to offer and charge a fee for acceptance of support, warranty, indemnity, or other liability obligations. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
67
|
+
|
|
68
|
+
END OF TERMS AND CONDITIONS
|
agentsecure-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentsecure
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Local-first security runtime for AI coding agents
|
|
5
|
+
Home-page: https://github.com/ShellFrameAI/agentsecure-community
|
|
6
|
+
Author: ShellFrame AI
|
|
7
|
+
License: Apache-2.0
|
|
8
|
+
Project-URL: Source, https://github.com/ShellFrameAI/agentsecure-community
|
|
9
|
+
Project-URL: Changelog, https://github.com/ShellFrameAI/agentsecure-community/blob/main/CHANGELOG.md
|
|
10
|
+
Project-URL: Issues, https://github.com/ShellFrameAI/agentsecure-community/issues
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Security
|
|
19
|
+
Classifier: Environment :: Console
|
|
20
|
+
Classifier: Operating System :: OS Independent
|
|
21
|
+
Requires-Python: >=3.6
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
License-File: NOTICE
|
|
25
|
+
Requires-Dist: dataclasses; python_version < "3.7"
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
# AgentSecure Community
|
|
29
|
+
|
|
30
|
+
**By ShellFrame AI**
|
|
31
|
+
|
|
32
|
+
AgentSecure Community is the open-source community/lite edition of AgentSecure by ShellFrame AI. It is a local-first demo runtime for AI coding agents that shows how an agent can work in a real project while seeing virtual secrets instead of raw `.env` values.
|
|
33
|
+
|
|
34
|
+
This repository is intentionally scoped to local CLI, local command guard, basic policy config, local secret virtualization, and tests. Hosted cloud sync, enterprise policy management, billing/licensing, and sensitive commercial detection logic are not part of this release.
|
|
35
|
+
|
|
36
|
+
## Ownership
|
|
37
|
+
|
|
38
|
+
AgentSecure and ShellFrame AI are ShellFrame AI project names. This community repository is published to demonstrate the local-first secret virtualization model while keeping commercial/backend features private.
|
|
39
|
+
|
|
40
|
+
## What It Demonstrates
|
|
41
|
+
|
|
42
|
+
- Discover likely secrets in `.env` files and environment variables.
|
|
43
|
+
- Store real values locally under `.agentsecure/`.
|
|
44
|
+
- Expose virtual values such as `OPENAI_API_KEY=virt_openai_...`.
|
|
45
|
+
- Sanitize common `.env` reads through command-guard mode.
|
|
46
|
+
- Remove denied env values from agent-visible output.
|
|
47
|
+
- Keep basic network, process, and file policy in JSON.
|
|
48
|
+
|
|
49
|
+
Command-guard mode is a usability guard, not a hard sandbox. A determined process can bypass wrapper-based masking. Use workspace copy mode or OS sandboxing for stronger isolation.
|
|
50
|
+
|
|
51
|
+
## Install
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
python3 -m venv .venv
|
|
55
|
+
source .venv/bin/activate
|
|
56
|
+
python -m pip install --upgrade pip
|
|
57
|
+
python -m pip install -e .
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Quickstart
|
|
61
|
+
|
|
62
|
+
Run the safe local demo:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
agentsecure demo
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Expected output includes a virtual OpenAI key and an explanation that `DATABASE_URL_PROD` was removed by policy:
|
|
69
|
+
|
|
70
|
+
```text
|
|
71
|
+
Agent-visible output:
|
|
72
|
+
OPENAI_API_KEY=virt_openai_...
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Try it in a project:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
agentsecure init
|
|
79
|
+
printf 'OPENAI_API_KEY=sk-demo-local-secret-do-not-use\n' > .env
|
|
80
|
+
agentsecure run --protect-all -- python3 -c 'import subprocess; print(subprocess.check_output(["cat", ".env"]).decode())'
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The agent-visible output contains a `virt_...` token. The real `.env` remains local and unchanged.
|
|
84
|
+
|
|
85
|
+
## Example Policy
|
|
86
|
+
|
|
87
|
+
See [examples/agentsecure.community.json](examples/agentsecure.community.json) and [examples/.env.example](examples/.env.example).
|
|
88
|
+
|
|
89
|
+
Minimal policy shape:
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"env_policy": {
|
|
94
|
+
"OPENAI_API_KEY": {
|
|
95
|
+
"mode": "virtualize",
|
|
96
|
+
"reason": "Agents see a virtual token, not the local real value."
|
|
97
|
+
},
|
|
98
|
+
"DATABASE_URL_PROD": {
|
|
99
|
+
"mode": "deny",
|
|
100
|
+
"reason": "Production database credentials are never exposed."
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"network": {
|
|
104
|
+
"allow_domains": ["api.openai.com"],
|
|
105
|
+
"allow_ports": [80, 443],
|
|
106
|
+
"deny_ip_literals": true,
|
|
107
|
+
"deny_private_networks": true
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Common Commands
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
agentsecure init
|
|
116
|
+
agentsecure status
|
|
117
|
+
agentsecure doctor
|
|
118
|
+
agentsecure discover
|
|
119
|
+
agentsecure suggest
|
|
120
|
+
agentsecure env
|
|
121
|
+
agentsecure keys list
|
|
122
|
+
agentsecure network list
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Run an agent or command through local command guard:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
agentsecure run --protect-all -- codex
|
|
129
|
+
agentsecure run --protect-all -- claude
|
|
130
|
+
agentsecure run --protect-all -- python3 -c 'import subprocess; print(subprocess.check_output(["cat", ".env"]).decode())'
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Use workspace copy mode when you want review-before-apply:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
agentsecure run --runtime workspace --workspace-mode copy --protect-all --workspace-keep -- codex
|
|
137
|
+
agentsecure diff
|
|
138
|
+
agentsecure apply --dry-run
|
|
139
|
+
agentsecure apply
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Screenshots / GIFs
|
|
143
|
+
|
|
144
|
+
Planned public demo assets:
|
|
145
|
+
|
|
146
|
+
- `docs/assets/demo-command-guard.gif`: `agentsecure demo` showing a virtual key.
|
|
147
|
+
- `docs/assets/dotenv-masking.png`: before/after `.env` masking.
|
|
148
|
+
- `docs/assets/workspace-diff.png`: review-before-apply workflow.
|
|
149
|
+
|
|
150
|
+
## Repository Layout
|
|
151
|
+
|
|
152
|
+
```text
|
|
153
|
+
agentsecure/
|
|
154
|
+
cli/ CLI entry point
|
|
155
|
+
core/ models, config loading, policy helpers
|
|
156
|
+
guard/ local command guard and output sanitizer
|
|
157
|
+
discovery/ local secret discovery
|
|
158
|
+
implementations/ local secret, grant, policy, and audit storage
|
|
159
|
+
workspace/ safe workspace materialization and apply flow
|
|
160
|
+
examples/ community-safe config and fake .env examples
|
|
161
|
+
scripts/ release and safety scripts
|
|
162
|
+
tests/ unit and local integration tests
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Testing
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
source .venv/bin/activate
|
|
169
|
+
python3 -m unittest discover -s tests -p 'test_*.py' -v
|
|
170
|
+
python3 scripts/secret_scan.py .
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
CI runs tests across supported Python versions and runs the local secret scan.
|
|
174
|
+
|
|
175
|
+
## Public Release Boundary
|
|
176
|
+
|
|
177
|
+
This community release should not include hosted backend integration, enterprise policy sync, billing/licensing, production secrets, internal endpoints, or sensitive commercial heuristics. See [OPEN_SOURCE_PLAN.md](OPEN_SOURCE_PLAN.md) before publishing a public GitHub repository.
|
|
178
|
+
|
|
179
|
+
## License
|
|
180
|
+
|
|
181
|
+
Apache License 2.0 is suggested for the community release. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# AgentSecure Community
|
|
2
|
+
|
|
3
|
+
**By ShellFrame AI**
|
|
4
|
+
|
|
5
|
+
AgentSecure Community is the open-source community/lite edition of AgentSecure by ShellFrame AI. It is a local-first demo runtime for AI coding agents that shows how an agent can work in a real project while seeing virtual secrets instead of raw `.env` values.
|
|
6
|
+
|
|
7
|
+
This repository is intentionally scoped to local CLI, local command guard, basic policy config, local secret virtualization, and tests. Hosted cloud sync, enterprise policy management, billing/licensing, and sensitive commercial detection logic are not part of this release.
|
|
8
|
+
|
|
9
|
+
## Ownership
|
|
10
|
+
|
|
11
|
+
AgentSecure and ShellFrame AI are ShellFrame AI project names. This community repository is published to demonstrate the local-first secret virtualization model while keeping commercial/backend features private.
|
|
12
|
+
|
|
13
|
+
## What It Demonstrates
|
|
14
|
+
|
|
15
|
+
- Discover likely secrets in `.env` files and environment variables.
|
|
16
|
+
- Store real values locally under `.agentsecure/`.
|
|
17
|
+
- Expose virtual values such as `OPENAI_API_KEY=virt_openai_...`.
|
|
18
|
+
- Sanitize common `.env` reads through command-guard mode.
|
|
19
|
+
- Remove denied env values from agent-visible output.
|
|
20
|
+
- Keep basic network, process, and file policy in JSON.
|
|
21
|
+
|
|
22
|
+
Command-guard mode is a usability guard, not a hard sandbox. A determined process can bypass wrapper-based masking. Use workspace copy mode or OS sandboxing for stronger isolation.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
python3 -m venv .venv
|
|
28
|
+
source .venv/bin/activate
|
|
29
|
+
python -m pip install --upgrade pip
|
|
30
|
+
python -m pip install -e .
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Quickstart
|
|
34
|
+
|
|
35
|
+
Run the safe local demo:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
agentsecure demo
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Expected output includes a virtual OpenAI key and an explanation that `DATABASE_URL_PROD` was removed by policy:
|
|
42
|
+
|
|
43
|
+
```text
|
|
44
|
+
Agent-visible output:
|
|
45
|
+
OPENAI_API_KEY=virt_openai_...
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Try it in a project:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
agentsecure init
|
|
52
|
+
printf 'OPENAI_API_KEY=sk-demo-local-secret-do-not-use\n' > .env
|
|
53
|
+
agentsecure run --protect-all -- python3 -c 'import subprocess; print(subprocess.check_output(["cat", ".env"]).decode())'
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The agent-visible output contains a `virt_...` token. The real `.env` remains local and unchanged.
|
|
57
|
+
|
|
58
|
+
## Example Policy
|
|
59
|
+
|
|
60
|
+
See [examples/agentsecure.community.json](examples/agentsecure.community.json) and [examples/.env.example](examples/.env.example).
|
|
61
|
+
|
|
62
|
+
Minimal policy shape:
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"env_policy": {
|
|
67
|
+
"OPENAI_API_KEY": {
|
|
68
|
+
"mode": "virtualize",
|
|
69
|
+
"reason": "Agents see a virtual token, not the local real value."
|
|
70
|
+
},
|
|
71
|
+
"DATABASE_URL_PROD": {
|
|
72
|
+
"mode": "deny",
|
|
73
|
+
"reason": "Production database credentials are never exposed."
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"network": {
|
|
77
|
+
"allow_domains": ["api.openai.com"],
|
|
78
|
+
"allow_ports": [80, 443],
|
|
79
|
+
"deny_ip_literals": true,
|
|
80
|
+
"deny_private_networks": true
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Common Commands
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
agentsecure init
|
|
89
|
+
agentsecure status
|
|
90
|
+
agentsecure doctor
|
|
91
|
+
agentsecure discover
|
|
92
|
+
agentsecure suggest
|
|
93
|
+
agentsecure env
|
|
94
|
+
agentsecure keys list
|
|
95
|
+
agentsecure network list
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Run an agent or command through local command guard:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
agentsecure run --protect-all -- codex
|
|
102
|
+
agentsecure run --protect-all -- claude
|
|
103
|
+
agentsecure run --protect-all -- python3 -c 'import subprocess; print(subprocess.check_output(["cat", ".env"]).decode())'
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Use workspace copy mode when you want review-before-apply:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
agentsecure run --runtime workspace --workspace-mode copy --protect-all --workspace-keep -- codex
|
|
110
|
+
agentsecure diff
|
|
111
|
+
agentsecure apply --dry-run
|
|
112
|
+
agentsecure apply
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Screenshots / GIFs
|
|
116
|
+
|
|
117
|
+
Planned public demo assets:
|
|
118
|
+
|
|
119
|
+
- `docs/assets/demo-command-guard.gif`: `agentsecure demo` showing a virtual key.
|
|
120
|
+
- `docs/assets/dotenv-masking.png`: before/after `.env` masking.
|
|
121
|
+
- `docs/assets/workspace-diff.png`: review-before-apply workflow.
|
|
122
|
+
|
|
123
|
+
## Repository Layout
|
|
124
|
+
|
|
125
|
+
```text
|
|
126
|
+
agentsecure/
|
|
127
|
+
cli/ CLI entry point
|
|
128
|
+
core/ models, config loading, policy helpers
|
|
129
|
+
guard/ local command guard and output sanitizer
|
|
130
|
+
discovery/ local secret discovery
|
|
131
|
+
implementations/ local secret, grant, policy, and audit storage
|
|
132
|
+
workspace/ safe workspace materialization and apply flow
|
|
133
|
+
examples/ community-safe config and fake .env examples
|
|
134
|
+
scripts/ release and safety scripts
|
|
135
|
+
tests/ unit and local integration tests
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Testing
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
source .venv/bin/activate
|
|
142
|
+
python3 -m unittest discover -s tests -p 'test_*.py' -v
|
|
143
|
+
python3 scripts/secret_scan.py .
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
CI runs tests across supported Python versions and runs the local secret scan.
|
|
147
|
+
|
|
148
|
+
## Public Release Boundary
|
|
149
|
+
|
|
150
|
+
This community release should not include hosted backend integration, enterprise policy sync, billing/licensing, production secrets, internal endpoints, or sensitive commercial heuristics. See [OPEN_SOURCE_PLAN.md](OPEN_SOURCE_PLAN.md) before publishing a public GitHub repository.
|
|
151
|
+
|
|
152
|
+
## License
|
|
153
|
+
|
|
154
|
+
Apache License 2.0 is suggested for the community release. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Community stub package for private/local API integrations."""
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
from typing import List
|
|
5
|
+
|
|
6
|
+
from agentsecure.core.config import JsonConfigWriter
|
|
7
|
+
from agentsecure.core.key_service import KeyManagementError
|
|
8
|
+
from agentsecure.core.product import ProductService
|
|
9
|
+
from agentsecure.discovery.dotenv_scanner import DotenvSecretScanner
|
|
10
|
+
from agentsecure.discovery.env_scanner import EnvironmentSecretScanner
|
|
11
|
+
from agentsecure.discovery.patterns import mask_secret
|
|
12
|
+
from agentsecure.discovery.scanner import CompositeSecretScanner
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def scanner() -> CompositeSecretScanner:
|
|
16
|
+
return CompositeSecretScanner(
|
|
17
|
+
[
|
|
18
|
+
EnvironmentSecretScanner(),
|
|
19
|
+
DotenvSecretScanner(os.getcwd()),
|
|
20
|
+
]
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def load_config_data(config_path: str):
|
|
25
|
+
if not os.path.exists(config_path):
|
|
26
|
+
ProductService(config_path, scanner()).init_project()
|
|
27
|
+
with open(config_path, "r") as handle:
|
|
28
|
+
return json.load(handle)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def normalize_policy_path(path: str) -> str:
|
|
32
|
+
return os.path.normpath(path).lstrip(os.sep)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def normalize_domain(domain: str) -> str:
|
|
36
|
+
return domain.strip().lower().rstrip(".")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def print_discovered(discovered) -> None:
|
|
40
|
+
if not discovered:
|
|
41
|
+
print("No likely secrets found.", flush=True)
|
|
42
|
+
return
|
|
43
|
+
print("AgentSecure found possible secrets:", flush=True)
|
|
44
|
+
for index, secret in enumerate(discovered, 1):
|
|
45
|
+
print(
|
|
46
|
+
"[%s] %s from %s provider=%s value=%s"
|
|
47
|
+
% (index, secret.name, secret.source, secret.provider_hint, mask_secret(secret.value)),
|
|
48
|
+
flush=True,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def selected_indexes(value: str, count: int) -> List[int]:
|
|
53
|
+
if value == "all":
|
|
54
|
+
return list(range(count))
|
|
55
|
+
indexes = []
|
|
56
|
+
for part in value.split(","):
|
|
57
|
+
part = part.strip()
|
|
58
|
+
if not part:
|
|
59
|
+
continue
|
|
60
|
+
number = int(part)
|
|
61
|
+
if number < 1 or number > count:
|
|
62
|
+
raise KeyManagementError("selection out of range: %s" % number)
|
|
63
|
+
indexes.append(number - 1)
|
|
64
|
+
return indexes
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def update_protected_files(config_path: str, paths: List[str], add: bool) -> int:
|
|
68
|
+
config = load_config_data(config_path)
|
|
69
|
+
files = config.setdefault("files", {})
|
|
70
|
+
protected = list(files.get("protect_write", []))
|
|
71
|
+
if add:
|
|
72
|
+
for path in paths:
|
|
73
|
+
normalized = normalize_policy_path(path)
|
|
74
|
+
if normalized not in protected:
|
|
75
|
+
protected.append(normalized)
|
|
76
|
+
else:
|
|
77
|
+
remove = set(normalize_policy_path(path) for path in paths)
|
|
78
|
+
protected = [path for path in protected if path not in remove]
|
|
79
|
+
files["protect_write"] = protected
|
|
80
|
+
JsonConfigWriter().save(config_path, config)
|
|
81
|
+
print("Protected write paths:")
|
|
82
|
+
for path in protected:
|
|
83
|
+
print(" %s" % path)
|
|
84
|
+
return 0
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def update_allowed_domains(config_path: str, domains: List[str], add: bool) -> int:
|
|
88
|
+
config = load_config_data(config_path)
|
|
89
|
+
network = config.setdefault("network", {})
|
|
90
|
+
allowed = list(network.get("allow_domains", []))
|
|
91
|
+
if add:
|
|
92
|
+
for domain in domains:
|
|
93
|
+
normalized = normalize_domain(domain)
|
|
94
|
+
if normalized and normalized not in allowed:
|
|
95
|
+
allowed.append(normalized)
|
|
96
|
+
else:
|
|
97
|
+
remove = set(normalize_domain(domain) for domain in domains)
|
|
98
|
+
allowed = [domain for domain in allowed if domain not in remove]
|
|
99
|
+
network["allow_domains"] = allowed
|
|
100
|
+
JsonConfigWriter().save(config_path, config)
|
|
101
|
+
print("Allowed credential domains:")
|
|
102
|
+
for domain in allowed:
|
|
103
|
+
print(" %s" % domain)
|
|
104
|
+
return 0
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def cloud_features_enabled() -> bool:
|
|
108
|
+
return os.environ.get("AGENTSECURE_ENABLE_CLOUD", "").strip() == "1"
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def cloud_features_disabled() -> int:
|
|
112
|
+
sys.stderr.write(
|
|
113
|
+
"agentsecure: cloud features are not enabled in community mode "
|
|
114
|
+
"(set AGENTSECURE_ENABLE_CLOUD=1 in private builds)\n"
|
|
115
|
+
)
|
|
116
|
+
return 2
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import os
|
|
3
|
+
import shutil
|
|
4
|
+
import subprocess
|
|
5
|
+
import tempfile
|
|
6
|
+
|
|
7
|
+
from agentsecure.cli.common import load_config_data, scanner
|
|
8
|
+
from agentsecure.core.config import JsonConfigWriter
|
|
9
|
+
from agentsecure.core.key_service import KeyManagementService
|
|
10
|
+
from agentsecure.core.product import ProductService
|
|
11
|
+
from agentsecure.guard.sanitizer import SecretOutputSanitizer
|
|
12
|
+
from agentsecure.implementations.audit import JsonLineAuditLogger
|
|
13
|
+
from agentsecure.implementations.grant_store import LocalJsonGrantStore
|
|
14
|
+
from agentsecure.implementations.secret_store_factory import encrypted_secret_store_for_config
|
|
15
|
+
from agentsecure.workspace.materializer import make_tree_writable
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def run_demo(args: argparse.Namespace) -> int:
|
|
19
|
+
demo_dir = tempfile.mkdtemp(prefix="agentsecure-demo-")
|
|
20
|
+
current = os.getcwd()
|
|
21
|
+
try:
|
|
22
|
+
os.chdir(demo_dir)
|
|
23
|
+
config_path = os.path.join(demo_dir, "agentsecure.json")
|
|
24
|
+
env_path = os.path.join(demo_dir, ".env")
|
|
25
|
+
openai_secret = "sk-demo-local-secret-do-not-use"
|
|
26
|
+
database_secret = "postgres://demo:demo-password@production.example/app"
|
|
27
|
+
with open(env_path, "w") as handle:
|
|
28
|
+
handle.write("OPENAI_API_KEY=%s\n" % openai_secret)
|
|
29
|
+
handle.write("DATABASE_URL_PROD=%s\n" % database_secret)
|
|
30
|
+
|
|
31
|
+
ProductService(config_path, scanner()).init_project(force=True)
|
|
32
|
+
service = KeyManagementService(
|
|
33
|
+
config_path,
|
|
34
|
+
encrypted_secret_store_for_config(config_path),
|
|
35
|
+
LocalJsonGrantStore(os.path.join(demo_dir, ".agentsecure", "grants.json")),
|
|
36
|
+
JsonLineAuditLogger(os.path.join(demo_dir, ".agentsecure", "audit.log")),
|
|
37
|
+
)
|
|
38
|
+
openai_result = service.create_key(
|
|
39
|
+
env_name="OPENAI_API_KEY",
|
|
40
|
+
real_secret=openai_secret,
|
|
41
|
+
provider="openai",
|
|
42
|
+
ttl="2h",
|
|
43
|
+
)
|
|
44
|
+
service.create_key(
|
|
45
|
+
env_name="DATABASE_URL_PROD",
|
|
46
|
+
real_secret=database_secret,
|
|
47
|
+
provider="database",
|
|
48
|
+
ttl="2h",
|
|
49
|
+
)
|
|
50
|
+
config = load_config_data(config_path)
|
|
51
|
+
config.setdefault("env_policy", {})["DATABASE_URL_PROD"] = {
|
|
52
|
+
"mode": "deny",
|
|
53
|
+
"environment": "production",
|
|
54
|
+
"risk": "high",
|
|
55
|
+
"reason": "production database credentials are not exposed to local agents",
|
|
56
|
+
}
|
|
57
|
+
JsonConfigWriter().save(config_path, config)
|
|
58
|
+
|
|
59
|
+
raw_output = _demo_read_dotenv(demo_dir)
|
|
60
|
+
sanitizer = SecretOutputSanitizer.from_config_path(config_path)
|
|
61
|
+
agent_visible = sanitizer.sanitize_text(raw_output)
|
|
62
|
+
|
|
63
|
+
print("AgentSecure community demo (local only)")
|
|
64
|
+
print("Project: %s" % demo_dir)
|
|
65
|
+
print("Command: cat .env")
|
|
66
|
+
print("Decision: mask OPENAI_API_KEY and block DATABASE_URL_PROD")
|
|
67
|
+
print("")
|
|
68
|
+
print("Agent-visible output:")
|
|
69
|
+
print(agent_visible, end="" if agent_visible.endswith("\n") else "\n")
|
|
70
|
+
print("")
|
|
71
|
+
print("Why:")
|
|
72
|
+
print(" OPENAI_API_KEY was replaced with %s" % openai_result["virtual_token"])
|
|
73
|
+
print(" DATABASE_URL_PROD was removed because env_policy sets mode=deny")
|
|
74
|
+
print(" Real secret values stayed local in the demo project")
|
|
75
|
+
print(" No cloud service, billing service, or enterprise policy sync was used")
|
|
76
|
+
if args.keep:
|
|
77
|
+
print("")
|
|
78
|
+
print("Kept demo project: %s" % demo_dir)
|
|
79
|
+
return 0
|
|
80
|
+
finally:
|
|
81
|
+
os.chdir(current)
|
|
82
|
+
if not args.keep:
|
|
83
|
+
make_tree_writable(demo_dir)
|
|
84
|
+
shutil.rmtree(demo_dir, ignore_errors=True)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def _demo_read_dotenv(demo_dir: str) -> str:
|
|
88
|
+
try:
|
|
89
|
+
return subprocess.check_output(
|
|
90
|
+
["cat", ".env"],
|
|
91
|
+
cwd=demo_dir,
|
|
92
|
+
stderr=subprocess.STDOUT,
|
|
93
|
+
universal_newlines=True,
|
|
94
|
+
)
|
|
95
|
+
except (OSError, subprocess.SubprocessError):
|
|
96
|
+
with open(os.path.join(demo_dir, ".env"), "r") as handle:
|
|
97
|
+
return handle.read()
|