-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathobjects.go
More file actions
222 lines (215 loc) · 13.8 KB
/
Copy pathobjects.go
File metadata and controls
222 lines (215 loc) · 13.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
package rbac
import (
"net/http"
"github.com/flanksource/duty/rbac/policy"
)
var dbResourceObjMap = map[string]string{
"access_token": policy.ObjectAuthConfidential,
"access_tokens": policy.ObjectAuthConfidential,
"agents_summary": policy.ObjectMonitor,
"agents": policy.ObjectDatabasePublic,
"applications": policy.ObjectApplication,
"config_access_unwrapped": policy.ObjectApplication,
"config_access_summary": policy.ObjectApplication,
"analysis_by_component": policy.ObjectCatalog,
"analysis_by_config": policy.ObjectCatalog,
"analysis_summary_by_component": policy.ObjectCatalog,
"analysis_types": policy.ObjectDatabasePublic,
"analyzer_types": policy.ObjectDatabasePublic,
"artifacts": policy.ObjectArtifact,
"canaries_with_status": policy.ObjectCanary,
"canaries": policy.ObjectCanary,
"casbin_rule": policy.ObjectAuth,
"catalog_changes": policy.ObjectCatalog,
"change_types": policy.ObjectDatabasePublic,
"changes_by_component": policy.ObjectCatalog,
"check_component_relationships": policy.ObjectCanary,
"check_config_relationships": policy.ObjectCanary,
"check_labels": policy.ObjectDatabasePublic,
"check_names": policy.ObjectDatabasePublic,
"check_status_summary_hour": policy.ObjectCanary,
"check_statuses_1d": policy.ObjectCanary,
"check_statuses_1h": policy.ObjectCanary,
"check_statuses_5m": policy.ObjectCanary,
"check_statuses": policy.ObjectCanary,
"check_summary_by_component": policy.ObjectCanary,
"check_summary_by_config": policy.ObjectCatalog,
"check_summary_for_config": policy.ObjectCatalog,
"check_summary": policy.ObjectCanary,
"checks_by_component": policy.ObjectCanary,
"checks_by_config": policy.ObjectCanary,
"checks_status_artifacts": policy.ObjectCanary,
"checks": policy.ObjectCanary,
"comment_responders": policy.ObjectIncident,
"comments": policy.ObjectIncident,
"component_labels": policy.ObjectDatabasePublic,
"component_names_all": policy.ObjectTopology,
"component_names": policy.ObjectDatabasePublic,
"component_relationships": policy.ObjectTopology,
"component_types": policy.ObjectDatabasePublic,
"components_with_logs": policy.ObjectTopology,
"components": policy.ObjectTopology,
"config_analysis_analyzers": policy.ObjectCatalog,
"config_analysis_by_severity": policy.ObjectCatalog,
"config_analysis_items": policy.ObjectCatalog,
"config_analysis": policy.ObjectCatalog,
"config_changes_by_types": policy.ObjectCatalog,
"config_changes_items": policy.ObjectCatalog,
"config_changes": policy.ObjectCatalog,
"config_class_summary": policy.ObjectCatalog,
"config_classes": policy.ObjectDatabasePublic,
"config_component_relationships": policy.ObjectCatalog,
"config_detail": policy.ObjectCatalog,
"config_items_aws": policy.ObjectCatalog,
"config_items": policy.ObjectCatalog,
"config_labels": policy.ObjectDatabasePublic,
"config_names": policy.ObjectDatabasePublic,
"config_relationships": policy.ObjectCatalog,
"config_properties": policy.ObjectCatalog,
"config_scrapers_with_status": policy.ObjectMonitor,
"config_scrapers": policy.ObjectDatabaseSettings,
"config_statuses": policy.ObjectDatabasePublic,
"config_summary": policy.ObjectCatalog,
"config_tags": policy.ObjectDatabasePublic,
"config_tags_labels_keys": policy.ObjectDatabasePublic,
"component_labels_keys": policy.ObjectDatabasePublic,
"checks_labels_keys": policy.ObjectDatabasePublic,
"config_types": policy.ObjectDatabasePublic,
"configs": policy.ObjectCatalog,
"connections_list": policy.ObjectDatabasePublic,
"connections": policy.ObjectConnection,
"connection_details": policy.ObjectConnectionDetail,
"courier_message_dispatches": policy.ObjectAuthConfidential,
"courier_messaged_dispatches": policy.ObjectAuthConfidential,
"courier_messages": policy.ObjectAuthConfidential,
"event_queue_summary": policy.ObjectMonitor,
"event_queue": policy.ObjectDatabaseSystem,
"evidences": policy.ObjectIncident,
"failed_events": policy.ObjectMonitor,
"hypotheses": policy.ObjectIncident,
"identities": policy.ObjectDatabasePublic,
"identity_credential_identifiers": policy.ObjectAuthConfidential,
"identity_credential_types": policy.ObjectAuthConfidential,
"identity_credentials": policy.ObjectAuthConfidential,
"identity_recovery_addresses": policy.ObjectAuthConfidential,
"identity_recovery_codes": policy.ObjectAuthConfidential,
"identity_recovery_tokens": policy.ObjectAuthConfidential,
"identity_verifiable_addresses": policy.ObjectAuthConfidential,
"identity_verification_codes": policy.ObjectAuthConfidential,
"identity_verification_tokens": policy.ObjectAuthConfidential,
"incident_histories": policy.ObjectIncident,
"incident_relationships": policy.ObjectIncident,
"incident_rules": policy.ObjectIncident,
"incident_summary_by_component": policy.ObjectIncident,
"incident_summary": policy.ObjectIncident,
"incidents_by_component": policy.ObjectIncident,
"incidents_by_config": policy.ObjectIncident,
"incidents": policy.ObjectIncident,
"integrations_with_status": policy.ObjectMonitor,
"integrations": policy.ObjectMonitor,
"job_histories": policy.ObjectMonitor,
"job_history_latest_status": policy.ObjectMonitor,
"job_history_names": policy.ObjectMonitor,
"job_history": policy.ObjectMonitor,
"logging_backends": policy.ObjectDatabaseSettings,
"migration_logs": policy.ObjectDatabaseSystem,
"networks": policy.ObjectAuthConfidential,
"notification_send_history": policy.ObjectMonitor,
"notification_send_history_resources": policy.ObjectMonitor,
"notification_send_history_summary": policy.ObjectMonitor,
"rpc/notification_send_history_of_resource": policy.ObjectMonitor,
"notifications_summary": policy.ObjectMonitor,
"notifications": policy.ObjectNotification,
"notification_groups": policy.ObjectNotification,
"notification_group_resources": policy.ObjectNotification,
"notification_silences": policy.ObjectNotification,
"people_roles": policy.ObjectDatabasePublic,
"people": policy.ObjectPeople,
"permissions": policy.ObjectDatabaseSystem,
"permission_groups": policy.ObjectDatabaseSystem,
"permissions_summary": policy.ObjectDatabaseSystem,
"permissions_group_summary": policy.ObjectDatabaseSystem,
"playbook_action_agent_data": policy.ObjectPlaybooks,
"playbook_approvals": policy.ObjectPlaybooks,
"playbook_names": policy.ObjectDatabasePublic,
"playbook_run_actions": policy.ObjectPlaybooks,
"playbook_runs": policy.ObjectPlaybooks,
"playbooks_for_agent": policy.ObjectAgentPush,
"rpc/get_playbook_run_actions": policy.ObjectPlaybooks,
"playbooks": policy.ObjectPlaybooks,
"properties": policy.ObjectDatabaseSystem,
"push_queue_summary": policy.ObjectMonitor,
"responders": policy.ObjectIncident,
"rpc/lookup_component_config_id_related_components": policy.ObjectTopology,
"rpc/_related_config_ids_recursive": policy.ObjectCatalog,
"rpc/check_summary_for_component": policy.ObjectCanary,
"rpc/config_relationships_recursive": policy.ObjectCatalog,
"rpc/get_recursive_path": policy.ObjectCatalog,
"rpc/lookup_analysis_by_component": policy.ObjectTopology,
"rpc/lookup_changes_by_component": policy.ObjectTopology,
"rpc/lookup_component_by_property": policy.ObjectTopology,
"rpc/lookup_component_children": policy.ObjectTopology,
"rpc/lookup_component_incidents": policy.ObjectTopology,
"rpc/lookup_component_names": policy.ObjectTopology,
"rpc/lookup_component_relations": policy.ObjectTopology,
"rpc/lookup_components_by_check": policy.ObjectTopology,
"rpc/lookup_components_by_config": policy.ObjectTopology,
"rpc/lookup_config_children": policy.ObjectCatalog,
"rpc/lookup_config_relations": policy.ObjectCatalog,
"rpc/lookup_configs_by_component": policy.ObjectTopology,
"rpc/lookup_related_configs": policy.ObjectCatalog,
"rpc/related_changes_recursive": policy.ObjectCatalog,
"rpc/related_config_ids_recursive": policy.ObjectCatalog,
"rpc/related_config_ids": policy.ObjectCatalog,
"rpc/related_configs_recursive": policy.ObjectCatalog,
"rpc/related_configs": policy.ObjectCatalog,
"rpc/soft_delete_canary": policy.ObjectCanary,
"rpc/soft_delete_check": policy.ObjectCanary,
"rpc/uuid_to_ulid": policy.ObjectDatabasePublic,
"saved_query": policy.ObjectDatabasePublic,
"schema_migration": policy.ObjectAuthConfidential,
"scrape_plugins": policy.ObjectCatalog,
"selfservice_errors": policy.ObjectAuthConfidential,
"selfservice_login_flows": policy.ObjectAuthConfidential,
"selfservice_recovery_flows": policy.ObjectAuthConfidential,
"selfservice_registration_flows": policy.ObjectAuthConfidential,
"selfservice_settings_flows": policy.ObjectAuthConfidential,
"selfservice_verification_flows": policy.ObjectAuthConfidential,
"session_devices": policy.ObjectAuthConfidential,
"sessions": policy.ObjectAuthConfidential,
"severities": policy.ObjectDatabasePublic,
"team_components": policy.ObjectDatabasePublic,
"team_members": policy.ObjectDatabasePublic,
"teams_with_status": policy.ObjectDatabasePublic,
"teams": policy.ObjectDatabasePublic,
"topologies_with_status": policy.ObjectTopology,
"topologies": policy.ObjectTopology,
"topology": policy.ObjectTopology,
"views": policy.ObjectCatalog,
"config_access_logs": policy.ObjectCatalog,
"access_reviews": policy.ObjectCatalog,
"config_access": policy.ObjectCatalog,
"external_groups": policy.ObjectCatalog,
"external_roles": policy.ObjectCatalog,
"external_user_groups": policy.ObjectCatalog,
"external_users": policy.ObjectCatalog,
}
func GetObjectByTable(resource string) string {
if v, exists := dbResourceObjMap[resource]; exists {
return v
}
return ""
}
func GetActionFromHttpMethod(method string) string {
switch method {
case http.MethodGet:
return policy.ActionRead
case http.MethodPatch:
return policy.ActionUpdate
case http.MethodPost:
return policy.ActionCreate
case http.MethodDelete:
return policy.ActionDelete
}
return ""
}