secops 0.1.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.
- secops/__init__.py +22 -0
- secops/auth.py +79 -0
- secops/chronicle/__init__.py +19 -0
- secops/chronicle/client.py +941 -0
- secops/chronicle/models.py +166 -0
- secops/client.py +60 -0
- secops/exceptions.py +27 -0
- secops-0.1.0.dist-info/METADATA +608 -0
- secops-0.1.0.dist-info/RECORD +11 -0
- secops-0.1.0.dist-info/WHEEL +4 -0
- secops-0.1.0.dist-info/licenses/LICENSE +202 -0
secops/__init__.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Copyright 2025 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
#
|
|
15
|
+
"""Google SecOps SDK for Python."""
|
|
16
|
+
|
|
17
|
+
__version__ = "0.1.2"
|
|
18
|
+
|
|
19
|
+
from secops.client import SecOpsClient
|
|
20
|
+
from secops.auth import SecOpsAuth
|
|
21
|
+
|
|
22
|
+
__all__ = ["SecOpsClient", "SecOpsAuth"]
|
secops/auth.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Copyright 2025 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
#
|
|
15
|
+
"""Authentication handling for Google SecOps SDK."""
|
|
16
|
+
from typing import Optional, Dict, Any, List
|
|
17
|
+
from google.auth.credentials import Credentials
|
|
18
|
+
from google.oauth2 import service_account
|
|
19
|
+
import google.auth
|
|
20
|
+
from secops.exceptions import AuthenticationError
|
|
21
|
+
|
|
22
|
+
# Define default scopes needed for Chronicle API
|
|
23
|
+
CHRONICLE_SCOPES = [
|
|
24
|
+
"https://www.googleapis.com/auth/cloud-platform"
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
class SecOpsAuth:
|
|
28
|
+
"""Handles authentication for the Google SecOps SDK."""
|
|
29
|
+
|
|
30
|
+
def __init__(
|
|
31
|
+
self,
|
|
32
|
+
credentials: Optional[Credentials] = None,
|
|
33
|
+
service_account_path: Optional[str] = None,
|
|
34
|
+
service_account_info: Optional[Dict[str, Any]] = None,
|
|
35
|
+
scopes: Optional[List[str]] = None
|
|
36
|
+
):
|
|
37
|
+
"""Initialize authentication for SecOps.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
credentials: Optional pre-existing Google Auth credentials
|
|
41
|
+
service_account_path: Optional path to service account JSON key file
|
|
42
|
+
service_account_info: Optional service account JSON key data as dict
|
|
43
|
+
scopes: Optional list of OAuth scopes to request
|
|
44
|
+
"""
|
|
45
|
+
self.scopes = scopes or CHRONICLE_SCOPES
|
|
46
|
+
self.credentials = self._get_credentials(
|
|
47
|
+
credentials,
|
|
48
|
+
service_account_path,
|
|
49
|
+
service_account_info
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
def _get_credentials(
|
|
53
|
+
self,
|
|
54
|
+
credentials: Optional[Credentials],
|
|
55
|
+
service_account_path: Optional[str],
|
|
56
|
+
service_account_info: Optional[Dict[str, Any]]
|
|
57
|
+
) -> Credentials:
|
|
58
|
+
"""Get credentials from various sources."""
|
|
59
|
+
try:
|
|
60
|
+
if credentials:
|
|
61
|
+
return credentials.with_scopes(self.scopes)
|
|
62
|
+
|
|
63
|
+
if service_account_info:
|
|
64
|
+
return service_account.Credentials.from_service_account_info(
|
|
65
|
+
service_account_info,
|
|
66
|
+
scopes=self.scopes
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
if service_account_path:
|
|
70
|
+
return service_account.Credentials.from_service_account_file(
|
|
71
|
+
service_account_path,
|
|
72
|
+
scopes=self.scopes
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
# Try to get default credentials
|
|
76
|
+
credentials, project = google.auth.default(scopes=self.scopes)
|
|
77
|
+
return credentials
|
|
78
|
+
except Exception as e:
|
|
79
|
+
raise AuthenticationError(f"Failed to get credentials: {str(e)}")
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Copyright 2025 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
#
|
|
15
|
+
"""Chronicle API specific functionality."""
|
|
16
|
+
|
|
17
|
+
from secops.chronicle.client import ChronicleClient
|
|
18
|
+
|
|
19
|
+
__all__ = ["ChronicleClient"]
|