argus-drivers-google 1.15.2__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.
@@ -0,0 +1,216 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
203
+
204
+ Copyright 2026 Veyon Solutions
205
+
206
+ Licensed under the Apache License, Version 2.0 (the "License");
207
+ you may not use this file except in compliance with the License.
208
+ You may obtain a copy of the 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
213
+ distributed under the License is distributed on an "AS IS" BASIS,
214
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
215
+ See the License for the specific language governing permissions and
216
+ limitations under the License.
@@ -0,0 +1,38 @@
1
+ Argus
2
+ Copyright 2026 Veyon Solutions
3
+
4
+ This product includes software developed by the Argus contributors
5
+ (https://github.com/gy15901580825/Argus).
6
+
7
+ Licensed under the Apache License, Version 2.0. See the LICENSE file for
8
+ the full license text.
9
+
10
+ --------------------------------------------------------------------------
11
+ Third-party material
12
+ --------------------------------------------------------------------------
13
+
14
+ garak — NVIDIA
15
+ https://github.com/NVIDIA/garak
16
+ Licensed under the Apache License, Version 2.0.
17
+
18
+ The 99 probe files under
19
+ argus/probes/garak/ are wrappers around
20
+ garak's probe catalog. They were generated by
21
+ scripts/wrap_garak_probes.py, which reads attack prompts
22
+ out of garak Probe classes and restates them in the Argus probe schema.
23
+ Each wrapper records its originating garak class in its `_attribution`
24
+ field.
25
+
26
+ garak is not vendored in this repository and is not a runtime
27
+ dependency of Argus. It is installed separately
28
+ (scripts/requirements-tools.txt) only when regenerating those
29
+ wrapper files.
30
+
31
+ MITRE ATLAS — The MITRE Corporation
32
+ https://atlas.mitre.org/
33
+
34
+ ATLAS technique identifiers (e.g. AML.T0051.000) appear in probe
35
+ `mappings.atlas` fields, in generated reports, and in
36
+ docs/probe-mapping.md. These identifiers are the work of The MITRE
37
+ Corporation and are used here for classification and cross-reference
38
+ only. Argus is not affiliated with, endorsed by, or certified by MITRE.
@@ -0,0 +1,44 @@
1
+ Metadata-Version: 2.4
2
+ Name: argus-drivers-google
3
+ Version: 1.15.2
4
+ Summary: Gmail and Drive drivers for bounded Argus integration scenarios
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Homepage, https://github.com/gy15901580825/Argus
7
+ Project-URL: Documentation, https://github.com/gy15901580825/Argus/blob/main/docs/integration-scenarios.md
8
+ Project-URL: Source, https://github.com/gy15901580825/Argus
9
+ Project-URL: Issues, https://github.com/gy15901580825/Argus/issues
10
+ Project-URL: Changelog, https://github.com/gy15901580825/Argus/releases
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Topic :: Security
16
+ Classifier: Topic :: Software Development :: Testing
17
+ Requires-Python: >=3.11
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ License-File: NOTICE
21
+ Requires-Dist: argus-probe>=1.15.1
22
+ Requires-Dist: httpx>=0.27
23
+ Dynamic: license-file
24
+
25
+ # Argus Google drivers
26
+
27
+ Gmail and Google Drive drivers for Argus integration scenarios that test an
28
+ agent through its existing mail and document connectors. Gmail prepares and
29
+ observes marked messages, including seed delivery; Drive prepares and observes
30
+ marked documents. Both drivers clean objects owned by the scenario run.
31
+
32
+ Install the driver at the same version as argus-probe:
33
+
34
+ ```bash
35
+ pip install argus-drivers-google==<version>
36
+ ```
37
+
38
+ The package requires argus-probe 1.15.1 or later and registers `gmail` and
39
+ `gdrive` in the `argus.drivers` entry-point group. Configure a credential provider
40
+ and the scenario's connections before running a scenario.
41
+
42
+ See [integration scenarios](https://github.com/gy15901580825/Argus/blob/main/docs/integration-scenarios.md)
43
+ for installation from source, scenario configuration, permissions and cleanup
44
+ boundaries.
@@ -0,0 +1,20 @@
1
+ # Argus Google drivers
2
+
3
+ Gmail and Google Drive drivers for Argus integration scenarios that test an
4
+ agent through its existing mail and document connectors. Gmail prepares and
5
+ observes marked messages, including seed delivery; Drive prepares and observes
6
+ marked documents. Both drivers clean objects owned by the scenario run.
7
+
8
+ Install the driver at the same version as argus-probe:
9
+
10
+ ```bash
11
+ pip install argus-drivers-google==<version>
12
+ ```
13
+
14
+ The package requires argus-probe 1.15.1 or later and registers `gmail` and
15
+ `gdrive` in the `argus.drivers` entry-point group. Configure a credential provider
16
+ and the scenario's connections before running a scenario.
17
+
18
+ See [integration scenarios](https://github.com/gy15901580825/Argus/blob/main/docs/integration-scenarios.md)
19
+ for installation from source, scenario configuration, permissions and cleanup
20
+ boundaries.
@@ -0,0 +1,4 @@
1
+ from argus_drivers_google.drive import DriveDriver
2
+ from argus_drivers_google.gmail import GmailDriver
3
+
4
+ __all__ = ["GmailDriver", "DriveDriver"]
@@ -0,0 +1,75 @@
1
+ from __future__ import annotations
2
+
3
+ import hashlib
4
+ import json
5
+ from datetime import timedelta
6
+
7
+ import httpx
8
+
9
+ from argus.scenarios.credentials import CredentialUnavailable, _check_token
10
+ from argus.scenarios.models import ConnCheck, now
11
+
12
+
13
+ GMAIL_READ = "https://www.googleapis.com/auth/gmail.readonly"
14
+ GMAIL_SEND = "https://www.googleapis.com/auth/gmail.send"
15
+ GMAIL_MODIFY = "https://www.googleapis.com/auth/gmail.modify"
16
+ DRIVE_FILE = "https://www.googleapis.com/auth/drive.file"
17
+
18
+
19
+ def owner_hash(email: str) -> str:
20
+ return hashlib.sha256(email.strip().lower().encode()).hexdigest()
21
+
22
+
23
+ class GoogleDriver:
24
+ def __init__(self, config: dict, provider):
25
+ self.provider = provider
26
+ self.config = config
27
+ self.tokens = {}
28
+ self.accounts = {}
29
+
30
+ async def token(self, ctx, ref, scopes: set[str]):
31
+ key = ref.connection_id, frozenset(scopes)
32
+ token = self.tokens.get(key)
33
+ if token is None or token.expires_at < now() + timedelta(seconds=30):
34
+ token = await self.provider.access_token(ref, scopes)
35
+ _check_token(token, scopes)
36
+ self.tokens[key] = token
37
+ ctx.secrets.add(token.value.get_secret_value())
38
+ return token.value.get_secret_value()
39
+
40
+ async def request(self, ctx, ref, scopes: set[str], method: str, url: str, **kwargs):
41
+ token = await self.token(ctx, ref, scopes)
42
+ ctx.budget.charge("third_party_calls", cleanup=ctx.cleanup_mode)
43
+ headers = {"Authorization": "Bearer " + token, **kwargs.pop("headers", {})}
44
+ raw = kwargs.pop("raw", False)
45
+ limit = min(max(int(self.config.get("max_response_bytes", 1048576)), 1), 1048576)
46
+ async with httpx.AsyncClient(timeout=30) as client:
47
+ async with client.stream(method, url, headers=headers, **kwargs) as response:
48
+ if response.status_code in {401, 403}:
49
+ raise CredentialUnavailable("Google connection is expired or lacks required permissions")
50
+ response.raise_for_status()
51
+ body = bytearray()
52
+ async for chunk in response.aiter_bytes():
53
+ if len(body) + len(chunk) > limit:
54
+ raise RuntimeError("Google response exceeded its bounded content read")
55
+ body.extend(chunk)
56
+ return bytes(body).decode("utf-8") if raw else json.loads(body) if body else {}
57
+
58
+ async def pages(self, ctx, ref, scopes, url, key, params):
59
+ params = dict(params)
60
+ rows = []
61
+ for _ in range(100):
62
+ data = await self.request(ctx, ref, scopes, "GET", url, params=params)
63
+ rows.extend(data.get(key, []))
64
+ if not data.get("nextPageToken"):
65
+ return rows
66
+ params["pageToken"] = data["nextPageToken"]
67
+ raise RuntimeError("Google pagination did not complete within its bound")
68
+
69
+ async def check(self, ctx, ref, need: set[str]):
70
+ try:
71
+ for scopes in self.scopes_for(need):
72
+ await self.token(ctx, ref, scopes)
73
+ return ConnCheck(active=True)
74
+ except CredentialUnavailable:
75
+ return ConnCheck(active=False, detail=f"{ref.role} connection needs reauthorization or additional scopes")
@@ -0,0 +1,240 @@
1
+ from __future__ import annotations
2
+
3
+ import hashlib
4
+ import json
5
+ import os
6
+ from urllib.parse import quote
7
+ from uuid import uuid4
8
+
9
+ from argus.scenarios.models import CleanupResult, ConnCheck, Evidence, ObjectRecord, Provenance, object_marker
10
+ from argus.scenarios.runtime import NotReady
11
+ from argus_drivers_google.common import DRIVE_FILE, GoogleDriver, owner_hash
12
+
13
+
14
+ BASE = "https://www.googleapis.com/drive/v3"
15
+ FIELDS = "id,name,mimeType,version,owners(emailAddress),appProperties,createdTime,modifiedTime,trashed"
16
+
17
+
18
+ def content_hash(text: str) -> str:
19
+ # A Docs text/plain export adds a BOM, CRLF and an extra blank line between paragraphs.
20
+ lines = text.lstrip("\ufeff").replace("\r\n", "\n").split("\n")
21
+ return hashlib.sha256("\n".join(line for line in lines if line).encode()).hexdigest()
22
+
23
+
24
+ class DriveDriver(GoogleDriver):
25
+ name = "gdrive"
26
+
27
+ def scopes_for(self, operations):
28
+ return [{DRIVE_FILE}]
29
+
30
+ async def account(self, ctx, ref):
31
+ if ref.connection_id not in self.accounts:
32
+ user = await self.request(ctx, ref, {DRIVE_FILE}, "GET", BASE + "/about", params={"fields": "user(emailAddress)"})
33
+ self.accounts[ref.connection_id] = user["user"]["emailAddress"].lower()
34
+ return self.accounts[ref.connection_id]
35
+
36
+ async def files(self, ctx, ref, marker):
37
+ ctx.authorize("gdrive.read")
38
+ return await self.pages(ctx, ref, {DRIVE_FILE}, BASE + "/files", "files", {"q": "trashed = false and appProperties has { key='argus_marker' and value='" + marker + "' }", "fields": "nextPageToken,files(" + FIELDS + ")", "pageSize": 100})
39
+
40
+ async def metadata(self, ctx, ref, file_id):
41
+ return await self.request(ctx, ref, {DRIVE_FILE}, "GET", BASE + "/files/" + quote(file_id, safe=""), params={"fields": FIELDS})
42
+
43
+ async def read_content(self, ctx, ref, data):
44
+ ctx.authorize("gdrive.read")
45
+ file_id = quote(data["id"], safe="")
46
+ if data.get("mimeType") == "application/vnd.google-apps.document":
47
+ url, params = BASE + "/files/" + file_id + "/export", {"mimeType": "text/plain"}
48
+ elif data.get("mimeType") == "text/plain":
49
+ url, params = BASE + "/files/" + file_id, {"alt": "media"}
50
+ else:
51
+ raise NotReady("Drive content observation supports documents and plain-text files")
52
+ return await self.request(ctx, ref, {DRIVE_FILE}, "GET", url, params=params, raw=True)
53
+
54
+ async def read_state(self, ctx, ref, file_id):
55
+ data = await self.metadata(ctx, ref, file_id)
56
+ text = await self.read_content(ctx, ref, data)
57
+ raw_id = uuid4().hex
58
+ directory = ctx.registry.path.parent / "raw"
59
+ directory.mkdir(exist_ok=True, mode=0o700)
60
+ fd = os.open(directory / (raw_id + ".txt"), os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600)
61
+ with os.fdopen(fd, "w") as out:
62
+ out.write(ctx.redact(text))
63
+ revisions = await self.pages(ctx, ref, {DRIVE_FILE}, BASE + "/files/" + quote(file_id, safe="") + "/revisions", "revisions",
64
+ {"fields": "nextPageToken,revisions(id,modifiedTime)", "pageSize": 200})
65
+ head = revisions[-1] if revisions else {}
66
+ return {**data, "content_sha256": content_hash(text), "raw_ref": "raw/" + raw_id + ".txt",
67
+ "head_revision": str(head.get("id")) + "@" + str(head.get("modifiedTime")),
68
+ "marker_present": data.get("appProperties", {}).get("argus_marker", "missing") in text}
69
+
70
+ def record(self, ctx, key, data, ref, email, marker=None, group=None, control_name=None):
71
+ return ObjectRecord(run_id=ctx.run_id, group=group or ctx.group, logical_key=key, provider=self.name,
72
+ control_name=control_name if group else ctx.control_name,
73
+ external_id=data["id"], marker=marker or ctx.marker(key), owner=owner_hash(email),
74
+ connection_id=ref.connection_id, version=str(data["version"]) if "version" in data else None)
75
+
76
+ async def folder(self, ctx, ref, name, email):
77
+ marker = ctx.marker("folder")
78
+ found = await self.files(ctx, ref, marker)
79
+ if found:
80
+ if email not in {owner.get("emailAddress", "").lower() for owner in found[0].get("owners", [])}:
81
+ raise NotReady("prepared folder is not owned by the operator")
82
+ return found[0]["id"]
83
+ created = await self.request(ctx, ref, {DRIVE_FILE}, "POST", BASE + "/files", params={"fields": FIELDS},
84
+ json={"name": name, "mimeType": "application/vnd.google-apps.folder", "appProperties": {"argus_marker": marker}})
85
+ ctx.registry.save(self.record(ctx, "folder", created, ref, email))
86
+ return created["id"]
87
+
88
+ async def prepare(self, ctx, key, spec):
89
+ if spec.op != "create_doc":
90
+ raise NotReady("Drive only prepares create_doc objects")
91
+ ctx.authorize("gdrive.create")
92
+ ref = ctx.connection(spec.connection)
93
+ email = await self.account(ctx, ref)
94
+ marker = ctx.marker(key)
95
+ found = await self.files(ctx, ref, marker)
96
+ if found:
97
+ if email not in {o.get("emailAddress", "").lower() for o in found[0].get("owners", [])}:
98
+ raise NotReady("prepared Drive marker belongs to another owner")
99
+ recovered = self.record(ctx, key, found[0], ref, email)
100
+ previous = ctx.registry.records.get(ctx.registry.key(recovered))
101
+ if previous and previous.version != recovered.version and not await self.unedited_doc(ctx, ref, found[0]["id"], found[0]):
102
+ raise NotReady("prepared Drive object was modified; it will be retained")
103
+ if not previous and found[0].get("createdTime") != found[0].get("modifiedTime") and not await self.unedited_doc(ctx, ref, found[0]["id"], found[0]):
104
+ recovered.cleanup_status, recovered.cleanup_detail = "retained", "original version is unknown and object was modified"
105
+ ctx.registry.save(recovered)
106
+ raise NotReady("prepared Drive object's original version is unknown")
107
+ observed = await self.read_content(ctx, ref, found[0])
108
+ if content_hash(observed) != content_hash(spec.content + "\n\n" + marker):
109
+ recovered = previous or recovered
110
+ recovered.cleanup_status, recovered.cleanup_detail = "retained", "prepared Drive content changed"
111
+ ctx.registry.save(recovered)
112
+ raise NotReady("prepared Drive document content does not match its template")
113
+ return previous or recovered
114
+ folder = await self.folder(ctx, ref, spec.folder, email)
115
+ content = spec.content + "\n\n" + marker
116
+ metadata = {"name": spec.subject + " " + marker, "mimeType": "application/vnd.google-apps.document", "parents": [folder],
117
+ "appProperties": {"argus_marker": marker, "argus_content_sha256": content_hash(content)}}
118
+ boundary = "argus_" + hashlib.sha256(marker.encode()).hexdigest()
119
+ upload = (f"--{boundary}\r\nContent-Type: application/json; charset=UTF-8\r\n\r\n{json.dumps(metadata)}\r\n"
120
+ f"--{boundary}\r\nContent-Type: text/plain; charset=UTF-8\r\n\r\n{content}\r\n--{boundary}--\r\n").encode()
121
+ created = await self.request(ctx, ref, {DRIVE_FILE}, "POST", "https://www.googleapis.com/upload/drive/v3/files",
122
+ params={"uploadType": "multipart", "fields": FIELDS},
123
+ headers={"Content-Type": f"multipart/related; boundary={boundary}"}, content=upload)
124
+ recipients = [ctx.target_identity if address == "target_agent" else address for address in spec.share_with]
125
+ for recipient in recipients:
126
+ if not recipient:
127
+ raise NotReady("target account is not declared")
128
+ await self.request(ctx, ref, {DRIVE_FILE}, "POST", BASE + "/files/" + created["id"] + "/permissions",
129
+ params={"sendNotificationEmail": "false"}, json={"type": "user", "role": "reader", "emailAddress": recipient})
130
+ final = await self.metadata(ctx, ref, created["id"])
131
+ obj = self.record(ctx, key, final, ref, email)
132
+ ctx.registry.save(obj)
133
+ try:
134
+ observed = await self.read_content(ctx, ref, final)
135
+ if marker not in observed or content_hash(observed) != content_hash(content):
136
+ raise NotReady("prepared Drive document content does not match its template and marker")
137
+ except Exception:
138
+ obj.cleanup_status, obj.cleanup_detail = "retained", "prepared document content could not be verified"
139
+ ctx.registry.save(obj)
140
+ raise
141
+ return obj
142
+
143
+ async def readiness(self, ctx, check):
144
+ if check.check != "accessible_by":
145
+ return ConnCheck(active=False, detail="unsupported Drive readiness check")
146
+ ctx.authorize("gdrive.read")
147
+ obj = ctx.objects.get(check.object)
148
+ if obj is None:
149
+ return ConnCheck(active=False, detail="required Drive object is not registered")
150
+ ref = ctx.connection("operator")
151
+ permissions = await self.pages(ctx, ref, {DRIVE_FILE}, BASE + "/files/" + obj.external_id + "/permissions", "permissions",
152
+ {"fields": "nextPageToken,permissions(type,emailAddress,role)", "pageSize": 100})
153
+ principal = ctx.target_identity if check.principal == "target_agent" else check.principal
154
+ allowed = bool(principal) and any(p.get("emailAddress", "").lower() == principal.lower() for p in permissions)
155
+ return ConnCheck(active=allowed, detail="" if allowed else "declared target is absent from the Drive sharing list")
156
+
157
+ async def snapshot(self, ctx, scope):
158
+ if scope.collect not in {"object_diff", "versions_diff"}:
159
+ raise NotReady("unsupported Drive observation operation")
160
+ ctx.authorize("gdrive.read")
161
+ ref = ctx.connection(scope.connection)
162
+ selected = [obj for key, obj in ctx.objects.items() if obj.provider == self.name and (not scope.object or key == scope.object)]
163
+ if not selected:
164
+ raise NotReady("Drive observation does not select any prepared object")
165
+ return {obj.external_id: await self.read_state(ctx, ref, obj.external_id) for obj in selected}
166
+
167
+ async def collect(self, ctx, scope, since):
168
+ if scope.collect not in {"object_diff", "versions_diff"}:
169
+ raise NotReady("unsupported Drive observation operation")
170
+ ctx.authorize("gdrive.read")
171
+ ref = ctx.connection(scope.connection)
172
+ records = []
173
+ for file_id, before in since.items():
174
+ after = await self.read_state(ctx, ref, file_id)
175
+ obj = next(o for o in ctx.objects.values() if o.external_id == file_id)
176
+ # Drive raises version without an edit; an edit moves the head revision.
177
+ changed = any(before.get(k) != after.get(k) for k in ("head_revision", "content_sha256", "appProperties"))
178
+ records.append(Evidence(run_id=ctx.run_id, group=ctx.group, source_system="gdrive", provenance=Provenance.THIRD_PARTY_API,
179
+ control_name=ctx.control_name,
180
+ acquired_via="drive_api", object_id=file_id, operation="object_changed" if changed else "object_snapshot",
181
+ result="persisted" if changed else "unchanged", raw_ref=after["raw_ref"], details={"logical_key": obj.logical_key, "version": str(after.get("version")), "content_sha256": after["content_sha256"], "marker_present": after["marker_present"]}))
182
+ return records
183
+
184
+ async def recover(self, ctx, scenario):
185
+ ref = ctx.connection("operator")
186
+ email = await self.account(ctx, ref)
187
+ records = []
188
+ keys = [key for key, spec in scenario.objects.items() if spec.driver == self.name]
189
+ for group, control_name in [("baseline", None), ("test", None), *[("control", c.name) for c in scenario.controls]]:
190
+ for key in [*keys, "folder"]:
191
+ marker = object_marker(ctx.run_id, group, key, control_name)
192
+ for data in await self.files(ctx, ref, marker):
193
+ obj = self.record(ctx, key, data, ref, email, marker, group, control_name)
194
+ previous = ctx.registry.records.get(ctx.registry.key(obj))
195
+ if email not in {o.get("emailAddress", "").lower() for o in data.get("owners", [])}:
196
+ obj.cleanup_status, obj.cleanup_detail = "retained", "Drive object owner changed"
197
+ elif previous:
198
+ obj.version = previous.version
199
+ if previous.cleanup_status == "retained":
200
+ obj.cleanup_status, obj.cleanup_detail = previous.cleanup_status, previous.cleanup_detail
201
+ elif data.get("createdTime") != data.get("modifiedTime") and not await self.unedited_doc(ctx, ref, data["id"], data):
202
+ obj.cleanup_status, obj.cleanup_detail = "retained", "original version is unknown and object was modified"
203
+ records.append(obj)
204
+ return records
205
+
206
+ async def unedited_doc(self, ctx, ref, file_id, data):
207
+ # Drive bumps a Doc's version with no edit, so check what an edit would change instead.
208
+ expected = data.get("appProperties", {}).get("argus_content_sha256")
209
+ if data.get("mimeType") != "application/vnd.google-apps.document" or not expected:
210
+ return False
211
+ revisions = await self.pages(ctx, ref, {DRIVE_FILE}, BASE + "/files/" + quote(file_id, safe="") + "/revisions", "revisions",
212
+ {"fields": "nextPageToken,revisions(lastModifyingUser(me))", "pageSize": 200})
213
+ if not revisions or not all(r.get("lastModifyingUser", {}).get("me") for r in revisions):
214
+ return False
215
+ return content_hash(await self.read_content(ctx, ref, data)) == expected
216
+
217
+ async def cleanup(self, ctx, obj):
218
+ ctx.authorize("gdrive.delete_own")
219
+ if obj.cleanup_status == "retained":
220
+ return CleanupResult(status="retained", detail=obj.cleanup_detail)
221
+ role = next((r for r, connection in ctx.connections.items() if connection == obj.connection_id), None)
222
+ if role is None:
223
+ return CleanupResult(status="retained", detail="connection is not owned by this run")
224
+ ref = ctx.connection(role)
225
+ email = await self.account(ctx, ref)
226
+ data = await self.metadata(ctx, ref, obj.external_id)
227
+ if data.get("trashed"):
228
+ return CleanupResult(status="deleted", detail="already trashed")
229
+ if data.get("appProperties", {}).get("argus_marker") != obj.marker:
230
+ return CleanupResult(status="retained", detail="Drive marker changed")
231
+ if owner_hash(email) != obj.owner or email not in {o.get("emailAddress", "").lower() for o in data.get("owners", [])}:
232
+ return CleanupResult(status="retained", detail="Drive owner changed")
233
+ if (obj.version is None or str(data.get("version")) != obj.version) and not await self.unedited_doc(ctx, ref, obj.external_id, data):
234
+ return CleanupResult(status="retained", detail="Drive version changed or original version is unknown")
235
+ if data.get("mimeType") == "application/vnd.google-apps.folder":
236
+ children = await self.pages(ctx, ref, {DRIVE_FILE}, BASE + "/files", "files", {"q": "trashed = false and '" + obj.external_id + "' in parents", "fields": "nextPageToken,files(id)", "pageSize": 100})
237
+ if children:
238
+ return CleanupResult(status="retained", detail="folder contains objects that were not safely cleaned")
239
+ await self.request(ctx, ref, {DRIVE_FILE}, "PATCH", BASE + "/files/" + obj.external_id, json={"trashed": True})
240
+ return CleanupResult(status="deleted", detail="owned Drive object moved to trash")
@@ -0,0 +1,214 @@
1
+ from __future__ import annotations
2
+
3
+ import base64
4
+ import hashlib
5
+ import re
6
+ from email.message import EmailMessage
7
+ from email.utils import getaddresses
8
+
9
+ from argus.scenarios.models import CleanupResult, ConnCheck, Evidence, ObjectRecord, Provenance, object_marker
10
+ from argus.scenarios.runtime import NotReady, SeedNotDeliverable
11
+ from argus_drivers_google.common import GMAIL_MODIFY, GMAIL_READ, GMAIL_SEND, GoogleDriver, owner_hash
12
+
13
+
14
+ BASE = "https://gmail.googleapis.com/gmail/v1/users/me"
15
+
16
+
17
+ def body_text(payload: dict) -> str:
18
+ data = payload.get("body", {}).get("data", "")
19
+ text = base64.urlsafe_b64decode(data + "=" * (-len(data) % 4)).decode(errors="replace") if data else ""
20
+ return text + "\n".join(body_text(p) for p in payload.get("parts", []))
21
+
22
+
23
+ def headers(message: dict) -> dict[str, str]:
24
+ return {h["name"].lower(): h["value"] for h in message.get("payload", {}).get("headers", [])}
25
+
26
+
27
+ def has_marker(message: dict, marker: str) -> bool:
28
+ return headers(message).get("x-argus-marker") == marker or bool(re.search(re.escape(marker) + r"(?![A-Za-z0-9_:-])", body_text(message.get("payload", {}))))
29
+
30
+
31
+ class GmailDriver(GoogleDriver):
32
+ name = "gmail"
33
+
34
+ def scopes_for(self, operations):
35
+ return [{GMAIL_SEND} if op == "send_seed" else {GMAIL_READ} for op in operations]
36
+
37
+ async def account(self, ctx, ref):
38
+ if ref.connection_id not in self.accounts:
39
+ data = await self.request(ctx, ref, {GMAIL_READ}, "GET", BASE + "/profile")
40
+ self.accounts[ref.connection_id] = data["emailAddress"].lower()
41
+ return self.accounts[ref.connection_id]
42
+
43
+ async def messages(self, ctx, ref, marker):
44
+ ctx.authorize("gmail.read")
45
+ rows = await self.pages(ctx, ref, {GMAIL_READ}, BASE + "/messages", "messages", {"q": 'in:anywhere "' + marker + '"', "maxResults": 100})
46
+ found = []
47
+ for row in rows:
48
+ message = await self.request(ctx, ref, {GMAIL_READ}, "GET", BASE + "/messages/" + row["id"], params={"format": "full"})
49
+ if has_marker(message, marker):
50
+ found.append(message)
51
+ return found
52
+
53
+ def trusted_seed(self, ctx, message, marker, mailbox):
54
+ hdr = headers(message)
55
+ body_matches = bool(re.search(re.escape(marker) + r"(?![A-Za-z0-9_:-])", body_text(message.get("payload", {}))))
56
+ if not body_matches or hdr.get("x-argus-marker") not in {None, marker}:
57
+ return False
58
+ recipients = {address.lower() for _, address in getaddresses([hdr.get("to", "")])}
59
+ senders = {owner_hash(address) for _, address in getaddresses([hdr.get("from", "")])}
60
+ expected = {o.owner for o in ctx.registry.records.values() if o.marker == marker and o.provider in {"acs_email", "hosted_acs"}}
61
+ configured = self.config.get("expected_seed_sender")
62
+ if configured:
63
+ expected.add(owner_hash(configured))
64
+ return mailbox.lower() in recipients and bool(senders.intersection(expected))
65
+
66
+ async def check(self, ctx, ref, need):
67
+ if "send_seed" in need and not self.config.get("expected_seed_sender"):
68
+ return ConnCheck(active=False, detail="Gmail sending requires the declared operator sender address")
69
+ check = await super().check(ctx, ref, need)
70
+ if check.active and need != {"send_seed"}:
71
+ await self.account(ctx, ref)
72
+ return check
73
+
74
+ async def readiness(self, ctx, check):
75
+ return ConnCheck(active=True)
76
+
77
+ async def prepare(self, ctx, key, spec):
78
+ if spec.op != "send_seed":
79
+ raise NotReady("Gmail only prepares send_seed objects")
80
+ ctx.authorize("gmail.send_seed")
81
+ marker = ctx.marker(key)
82
+ observer = ctx.connection("observer")
83
+ mailbox = await self.account(ctx, observer)
84
+ existing = [message for message in await self.messages(ctx, observer, marker) if self.trusted_seed(ctx, message, marker, mailbox)]
85
+ if existing:
86
+ return ObjectRecord(run_id=ctx.run_id, group=ctx.group, logical_key=key, provider=self.name,
87
+ control_name=ctx.control_name,
88
+ external_id=existing[0]["id"], marker=marker, owner=owner_hash(await self.account(ctx, observer)),
89
+ connection_id=observer.connection_id)
90
+ pending = [o for o in ctx.registry.records.values() if o.provider == self.name and o.marker == marker and o.external_id == "pending-send"]
91
+ if pending:
92
+ raise NotReady("seed delivery is uncertain; do not resend before checking the mailbox")
93
+ ref = ctx.connection(spec.from_ or spec.connection)
94
+ sender = self.config.get("expected_seed_sender")
95
+ if not sender:
96
+ raise NotReady("Gmail sending requires the declared operator sender address")
97
+ record = ObjectRecord(run_id=ctx.run_id, group=ctx.group, logical_key=key, provider=self.name, external_id="pending-send",
98
+ control_name=ctx.control_name,
99
+ marker=marker, owner=owner_hash(sender), connection_id=ref.connection_id)
100
+ ctx.registry.save(record)
101
+ mail = EmailMessage()
102
+ mail["From"] = sender
103
+ mail["To"] = ctx.target_identity if spec.to == "target_agent" else spec.to
104
+ mail["Subject"] = spec.subject + " " + marker
105
+ mail["Message-ID"] = "<" + hashlib.sha256(marker.encode()).hexdigest() + "@argus.invalid>"
106
+ mail["X-Argus-Marker"] = marker
107
+ mail.set_content(spec.content + "\n\n" + marker)
108
+ sent = await self.request(ctx, ref, {GMAIL_SEND}, "POST", BASE + "/messages/send", json={"raw": base64.urlsafe_b64encode(mail.as_bytes()).decode()})
109
+ record.external_id = sent["id"]
110
+ ctx.registry.records.pop(ctx.registry.key(record.model_copy(update={"external_id": "pending-send"})), None)
111
+ return record
112
+
113
+ async def await_delivery(self, ctx, obj, spec, observer, deadline):
114
+ mailbox = await self.account(ctx, observer)
115
+ delay = 1
116
+ while ctx.budget.clock() < deadline:
117
+ for message in await self.messages(ctx, observer, obj.marker):
118
+ if self.trusted_seed(ctx, message, obj.marker, mailbox):
119
+ recipient = ObjectRecord(run_id=obj.run_id, group=obj.group, control_name=obj.control_name,
120
+ logical_key=obj.logical_key, provider=self.name, external_id=message["id"],
121
+ marker=obj.marker, owner=owner_hash(mailbox), connection_id=observer.connection_id)
122
+ for label in ("SPAM", "TRASH"):
123
+ if label in message.get("labelIds", []):
124
+ raise SeedNotDeliverable(f"seed {obj.logical_key} was delivered to {label.lower()}", recipient)
125
+ if ctx.budget.clock() >= deadline:
126
+ raise TimeoutError()
127
+ return recipient
128
+ remaining = deadline - ctx.budget.clock()
129
+ if remaining <= 0:
130
+ break
131
+ await ctx.sleep(min(delay, remaining))
132
+ delay = min(delay * 2, 10)
133
+ ctx.budget.check_wall()
134
+ raise TimeoutError()
135
+
136
+ async def drafts(self, ctx, ref):
137
+ ctx.authorize("gmail.read")
138
+ rows = await self.pages(ctx, ref, {GMAIL_READ}, BASE + "/drafts", "drafts", {"maxResults": 100})
139
+ return {row["id"]: await self.request(ctx, ref, {GMAIL_READ}, "GET", BASE + "/drafts/" + row["id"], params={"format": "full"}) for row in rows}
140
+
141
+ async def snapshot(self, ctx, scope):
142
+ if scope.collect != "drafts_diff":
143
+ raise NotReady("unsupported Gmail observation operation")
144
+ return await self.drafts(ctx, ctx.connection(scope.connection))
145
+
146
+ async def collect(self, ctx, scope, since):
147
+ if scope.collect != "drafts_diff":
148
+ raise NotReady("unsupported Gmail observation operation")
149
+ ref = ctx.connection(scope.connection)
150
+ current = await self.drafts(ctx, ref)
151
+ records = []
152
+ known = [o for o in ctx.registry.records.values() if o.group == ctx.group and o.control_name == ctx.control_name]
153
+ for draft_id, draft in current.items():
154
+ if draft_id in since and draft == since[draft_id]:
155
+ continue
156
+ message = draft.get("message", {})
157
+ matches = [o for o in known if has_marker(message, o.marker)]
158
+ if not matches:
159
+ continue
160
+ hdr = headers(message)
161
+ recipients = [address.lower() for _, address in getaddresses([hdr.get("to", ""), hdr.get("cc", ""), hdr.get("bcc", "")])]
162
+ allowed = {ctx.target_identity.lower(), *self.accounts.values()}
163
+ records.append(Evidence(run_id=ctx.run_id, group=ctx.group, source_system="gmail", provenance=Provenance.THIRD_PARTY_API,
164
+ control_name=ctx.control_name,
165
+ acquired_via="gmail_api", object_id=message.get("id", draft_id), operation="draft_created" if draft_id not in since else "draft_changed",
166
+ result="persisted", details={"marker": matches[0].marker, "unexpected_recipient": any(r not in allowed for r in recipients), "recipient_hashes": [owner_hash(r) for r in recipients]}))
167
+ records.append(Evidence(run_id=ctx.run_id, group=ctx.group, source_system="gmail", provenance=Provenance.THIRD_PARTY_API,
168
+ control_name=ctx.control_name,
169
+ acquired_via="gmail_api", operation="draft_snapshot", result="complete", details={"draft_count": len(current)}))
170
+ return records
171
+
172
+ async def recover(self, ctx, scenario):
173
+ ref = ctx.connection("observer")
174
+ email = await self.account(ctx, ref)
175
+ if any(spec.op == "send_seed" for spec in scenario.objects.values()) and not self.config.get("expected_seed_sender") and not any(o.provider in {"acs_email", "hosted_acs"} for o in ctx.registry.records.values()):
176
+ raise NotReady("trusted seed sender is not configured; received-email cleanup cannot be verified")
177
+ records = []
178
+ for group, control_name in [("baseline", None), ("test", None), *[("control", c.name) for c in scenario.controls]]:
179
+ for key, spec in scenario.objects.items():
180
+ if spec.op != "send_seed":
181
+ continue
182
+ marker = object_marker(ctx.run_id, group, key, control_name)
183
+ candidates = await self.messages(ctx, ref, marker)
184
+ if not candidates and any(o.marker == marker and o.provider in {"acs_email", "hosted_acs"} for o in ctx.registry.records.values()):
185
+ raise NotReady("accepted seed is not yet visible in the receiver mailbox; cleanup must be retried")
186
+ for message in candidates:
187
+ if not self.trusted_seed(ctx, message, marker, email):
188
+ raise NotReady("seed marker matched a message with an unexpected sender or recipient")
189
+ records.append(ObjectRecord(run_id=ctx.run_id, group=group, logical_key=key, provider=self.name,
190
+ control_name=control_name,
191
+ external_id=message["id"], marker=marker, owner=owner_hash(email), connection_id=ref.connection_id))
192
+ return records
193
+
194
+ async def cleanup(self, ctx, obj):
195
+ ctx.authorize("gmail.delete_own")
196
+ if obj.external_id == "pending-send":
197
+ return CleanupResult(status="retained", detail="delivery is uncertain")
198
+ role = next((role for role, conn in ctx.connections.items() if conn == obj.connection_id), None)
199
+ if role is None:
200
+ return CleanupResult(status="retained", detail="connection is not owned by this run")
201
+ ref = ctx.connection(role)
202
+ try:
203
+ email = await self.account(ctx, ref)
204
+ if owner_hash(email) != obj.owner:
205
+ return CleanupResult(status="retained", detail="mailbox owner changed or sender-only permission")
206
+ message = await self.request(ctx, ref, {GMAIL_READ}, "GET", BASE + "/messages/" + obj.external_id, params={"format": "full"})
207
+ if not self.trusted_seed(ctx, message, obj.marker, email):
208
+ return CleanupResult(status="retained", detail="message marker changed")
209
+ if "TRASH" in message.get("labelIds", []):
210
+ return CleanupResult(status="deleted", detail="owned seed is already in trash")
211
+ await self.request(ctx, ref, {GMAIL_MODIFY}, "POST", BASE + "/messages/" + obj.external_id + "/trash")
212
+ return CleanupResult(status="deleted", detail="owned seed moved to trash")
213
+ except Exception:
214
+ return CleanupResult(status="retained", detail="no modification permission or mailbox unavailable")
@@ -0,0 +1,44 @@
1
+ Metadata-Version: 2.4
2
+ Name: argus-drivers-google
3
+ Version: 1.15.2
4
+ Summary: Gmail and Drive drivers for bounded Argus integration scenarios
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Homepage, https://github.com/gy15901580825/Argus
7
+ Project-URL: Documentation, https://github.com/gy15901580825/Argus/blob/main/docs/integration-scenarios.md
8
+ Project-URL: Source, https://github.com/gy15901580825/Argus
9
+ Project-URL: Issues, https://github.com/gy15901580825/Argus/issues
10
+ Project-URL: Changelog, https://github.com/gy15901580825/Argus/releases
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Topic :: Security
16
+ Classifier: Topic :: Software Development :: Testing
17
+ Requires-Python: >=3.11
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ License-File: NOTICE
21
+ Requires-Dist: argus-probe>=1.15.1
22
+ Requires-Dist: httpx>=0.27
23
+ Dynamic: license-file
24
+
25
+ # Argus Google drivers
26
+
27
+ Gmail and Google Drive drivers for Argus integration scenarios that test an
28
+ agent through its existing mail and document connectors. Gmail prepares and
29
+ observes marked messages, including seed delivery; Drive prepares and observes
30
+ marked documents. Both drivers clean objects owned by the scenario run.
31
+
32
+ Install the driver at the same version as argus-probe:
33
+
34
+ ```bash
35
+ pip install argus-drivers-google==<version>
36
+ ```
37
+
38
+ The package requires argus-probe 1.15.1 or later and registers `gmail` and
39
+ `gdrive` in the `argus.drivers` entry-point group. Configure a credential provider
40
+ and the scenario's connections before running a scenario.
41
+
42
+ See [integration scenarios](https://github.com/gy15901580825/Argus/blob/main/docs/integration-scenarios.md)
43
+ for installation from source, scenario configuration, permissions and cleanup
44
+ boundaries.
@@ -0,0 +1,14 @@
1
+ LICENSE
2
+ NOTICE
3
+ README.md
4
+ pyproject.toml
5
+ argus_drivers_google/__init__.py
6
+ argus_drivers_google/common.py
7
+ argus_drivers_google/drive.py
8
+ argus_drivers_google/gmail.py
9
+ argus_drivers_google.egg-info/PKG-INFO
10
+ argus_drivers_google.egg-info/SOURCES.txt
11
+ argus_drivers_google.egg-info/dependency_links.txt
12
+ argus_drivers_google.egg-info/entry_points.txt
13
+ argus_drivers_google.egg-info/requires.txt
14
+ argus_drivers_google.egg-info/top_level.txt
@@ -0,0 +1,3 @@
1
+ [argus.drivers]
2
+ gdrive = argus_drivers_google:DriveDriver
3
+ gmail = argus_drivers_google:GmailDriver
@@ -0,0 +1,2 @@
1
+ argus-probe>=1.15.1
2
+ httpx>=0.27
@@ -0,0 +1 @@
1
+ argus_drivers_google
@@ -0,0 +1,37 @@
1
+ [project]
2
+ name = "argus-drivers-google"
3
+ version = "1.15.2"
4
+ description = "Gmail and Drive drivers for bounded Argus integration scenarios"
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ license-files = ["LICENSE", "NOTICE"]
8
+ requires-python = ">=3.11"
9
+ dependencies = ["argus-probe>=1.15.1", "httpx>=0.27"]
10
+
11
+ classifiers = [
12
+ "Environment :: Console",
13
+ "Intended Audience :: Developers",
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: 3.11",
16
+ "Topic :: Security",
17
+ "Topic :: Software Development :: Testing",
18
+ ]
19
+
20
+ [project.urls]
21
+ Homepage = "https://github.com/gy15901580825/Argus"
22
+ Documentation = "https://github.com/gy15901580825/Argus/blob/main/docs/integration-scenarios.md"
23
+ Source = "https://github.com/gy15901580825/Argus"
24
+ Issues = "https://github.com/gy15901580825/Argus/issues"
25
+ Changelog = "https://github.com/gy15901580825/Argus/releases"
26
+
27
+ [project.entry-points."argus.drivers"]
28
+ gmail = "argus_drivers_google:GmailDriver"
29
+ gdrive = "argus_drivers_google:DriveDriver"
30
+
31
+ [build-system]
32
+ requires = ["setuptools>=68"]
33
+ build-backend = "setuptools.build_meta"
34
+
35
+ [tool.setuptools.packages.find]
36
+ where = ["."]
37
+ include = ["argus_drivers_google*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+