Skip to content

Commit 5b5a319

Browse files
committed
python(feat): Add reports and tags types and clients + clean up rules as a result.
1 parent 39cfddb commit 5b5a319

29 files changed

Lines changed: 2521 additions & 307 deletions

File tree

protos/sift/rule_evaluation/v1/rule_evaluation.proto

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,8 @@ message EvaluateRulesFromRuleConfigs {
130130
repeated sift.rules.v1.UpdateRuleRequest configs = 1 [(google.api.field_behavior) = REQUIRED];
131131
}
132132

133-
message RulePreviewOutput {
134-
string rule_name = 1 [(google.api.field_behavior) = REQUIRED];
135-
string rule_id = 2;
136-
string rule_version_id = 3;
137-
string asset_id = 4 [(google.api.field_behavior) = REQUIRED];
138-
int32 exit_code = 5 [(google.api.field_behavior) = REQUIRED];
139-
string stdout = 6;
140-
string stderr = 7;
141-
}
142133

143134
message EvaluateRulesPreviewResponse {
144135
int32 created_annotation_count = 1 [(google.api.field_behavior) = REQUIRED];
145136
repeated sift.rules.v1.DryRunAnnotation dry_run_annotations = 2;
146-
repeated RulePreviewOutput rule_outputs = 3;
147137
}

protos/sift/rules/v1/rules.proto

Lines changed: 114 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,51 +101,107 @@ service RuleService {
101101
};
102102
}
103103

104-
// Deletes a rule
104+
// Deprecated - use ArchiveRule instead.
105+
// Archives a rule.
105106
rpc DeleteRule(DeleteRuleRequest) returns (DeleteRuleResponse) {
107+
option deprecated = true;
106108
option (google.api.http) = {
107109
post: "/api/v1/rules/delete"
108110
body: "*"
109111
};
110112
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
111113
summary: "DeleteRule"
112-
description: "Deletes a rule."
114+
description: "Archives a rule. Deprecated: Use ArchiveRule instead."
115+
};
116+
}
117+
118+
// Archives a rule.
119+
rpc ArchiveRule(ArchiveRuleRequest) returns (ArchiveRuleResponse) {
120+
option (google.api.http) = {
121+
post: "/api/v1/rules/archive"
122+
body: "*"
123+
};
124+
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
125+
summary: "ArchiveRule"
126+
description: "Archives a rule."
113127
};
114128
}
115129

116-
// Deletes multiple rules
130+
// Deprecated - use BatchArchiveRules instead.
131+
// Archives multiple rules.
117132
rpc BatchDeleteRules(BatchDeleteRulesRequest) returns (BatchDeleteRulesResponse) {
133+
option deprecated = true;
118134
option (google.api.http) = {
119135
post: "/api/v1/rules/batchDelete"
120136
body: "*"
121137
};
122138
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
123139
summary: "BatchDeleteRules"
124-
description: "Deletes multiple rules."
140+
description: "Archives multiple rules. Deprecated: Use BatchArchiveRules instead."
125141
};
126142
}
127143

128-
// Undeletes a rule
144+
// Batch archives rules.
145+
rpc BatchArchiveRules(BatchArchiveRulesRequest) returns (BatchArchiveRulesResponse) {
146+
option (google.api.http) = {
147+
post: "/api/v1/rules/batchArchive"
148+
body: "*"
149+
};
150+
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
151+
summary: "BatchArchiveRules"
152+
description: "Batch archives rules."
153+
};
154+
}
155+
156+
// Unarchives a rule.
157+
rpc UnarchiveRule(UnarchiveRuleRequest) returns (UnarchiveRuleResponse) {
158+
option (google.api.http) = {
159+
post: "/api/v1/rules/unarchive"
160+
body: "*"
161+
};
162+
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
163+
summary: "UnarchiveRule"
164+
description: "Unarchives a rule."
165+
};
166+
}
167+
168+
// Batch unarchives rules.
169+
rpc BatchUnarchiveRules(BatchUnarchiveRulesRequest) returns (BatchUnarchiveRulesResponse) {
170+
option (google.api.http) = {
171+
post: "/api/v1/rules/batchUnarchive"
172+
body: "*"
173+
};
174+
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
175+
summary: "BatchUnarchiveRules"
176+
description: "Batch unarchives rules."
177+
};
178+
}
179+
180+
// Deprecated - use UnarchiveRule instead.
181+
// Unarchives a rule
129182
rpc UndeleteRule(UndeleteRuleRequest) returns (UndeleteRuleResponse) {
183+
option deprecated = true;
130184
option (google.api.http) = {
131185
post: "/api/v1/rules/undelete"
132186
body: "*"
133187
};
134188
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
135189
summary: "UndeleteRule"
136-
description: "Undeletes a rule."
190+
description: "Deprecated: Use UnarchiveRule instead."
137191
};
138192
}
139193

140-
// Undeletes multiple rules
194+
// Deprecated - use BatchUnarchiveRules instead.
195+
// Unarchives multiple rules
141196
rpc BatchUndeleteRules(BatchUndeleteRulesRequest) returns (BatchUndeleteRulesResponse) {
197+
option deprecated = true;
142198
option (google.api.http) = {
143199
post: "/api/v1/rules/batchUndelete"
144200
body: "*"
145201
};
146202
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
147203
summary: "BatchUndeleteRules"
148-
description: "Undeletes multiple rules."
204+
description: "Deprecated: Use BatchUnarchiveRules instead."
149205
};
150206
}
151207

@@ -284,9 +340,18 @@ message Rule {
284340

285341
RuleAssetConfiguration asset_configuration = 15 [(google.api.field_behavior) = REQUIRED];
286342
ContextualChannels contextual_channels = 16 [(google.api.field_behavior) = REQUIRED];
287-
google.protobuf.Timestamp deleted_date = 17 [(google.api.field_behavior) = OPTIONAL];
343+
google.protobuf.Timestamp deleted_date = 17 [
344+
(google.api.field_behavior) = OPTIONAL,
345+
deprecated = true
346+
];
288347
bool is_external = 18 [(google.api.field_behavior) = REQUIRED];
289348
repeated sift.metadata.v1.MetadataValue metadata = 19 [(google.api.field_behavior) = REQUIRED];
349+
350+
// archived_date indicates when the rule was archived
351+
google.protobuf.Timestamp archived_date = 20 [(google.api.field_behavior) = OPTIONAL];
352+
353+
// is_archived is inferred from when archived_date is not null
354+
bool is_archived = 21 [(google.api.field_behavior) = REQUIRED];
290355
}
291356
message RuleCondition {
292357
// 4 is reserved from old "status" column that lived directly on rule condition
@@ -410,6 +475,7 @@ message UpdateRuleRequest {
410475
ContextualChannels contextual_channels = 11;
411476
bool is_external = 12;
412477
repeated sift.metadata.v1.MetadataValue metadata = 13 [(google.api.field_behavior) = REQUIRED];
478+
bool is_archived = 14 [(google.api.field_behavior) = OPTIONAL];
413479
}
414480
message UpdateConditionRequest {
415481
// 2 is reserved from old status update support on rule condition directly
@@ -496,6 +562,20 @@ message BatchDeleteRulesRequest {
496562
}
497563
message BatchDeleteRulesResponse {}
498564

565+
// ArchiveRuleRequest is used to archive a rule by rule_id or client_key. If both are provided, only rule_id will be used.
566+
message ArchiveRuleRequest {
567+
string rule_id = 1 [(google.api.field_behavior) = OPTIONAL];
568+
string client_key = 2 [(google.api.field_behavior) = OPTIONAL];
569+
}
570+
message ArchiveRuleResponse {}
571+
572+
// BatchArchiveRulesRequest is used to archive a rule by rule_id or client_key. For each rule if both are provided, only rule_id will be used.
573+
message BatchArchiveRulesRequest {
574+
repeated string rule_ids = 1 [(google.api.field_behavior) = OPTIONAL];
575+
repeated string client_keys = 2 [(google.api.field_behavior) = OPTIONAL];
576+
}
577+
message BatchArchiveRulesResponse {}
578+
499579
// UndeleteRuleRequest is used to undelete a rule by rule_id or client_key. If both are provided, only rule_id will be used.
500580
message UndeleteRuleRequest {
501581
string rule_id = 1 [(google.api.field_behavior) = OPTIONAL];
@@ -510,6 +590,20 @@ message BatchUndeleteRulesRequest {
510590
}
511591
message BatchUndeleteRulesResponse {}
512592

593+
// UnarchiveRuleRequest is used to unarchive a rule by rule_id or client_key. If both are provided, only rule_id will be used.
594+
message UnarchiveRuleRequest {
595+
string rule_id = 1 [(google.api.field_behavior) = OPTIONAL];
596+
string client_key = 2 [(google.api.field_behavior) = OPTIONAL];
597+
}
598+
message UnarchiveRuleResponse {}
599+
600+
// BatchUnarchiveRulesRequest is used to unarchive a rule by rule_id or client_key. For each rule if both are provided, only rule_id will be used.
601+
message BatchUnarchiveRulesRequest {
602+
repeated string rule_ids = 1 [(google.api.field_behavior) = OPTIONAL];
603+
repeated string client_keys = 2 [(google.api.field_behavior) = OPTIONAL];
604+
}
605+
message BatchUnarchiveRulesResponse {}
606+
513607
// Deprecated - use ViewJsonRulesRequest.
514608
message ViewHumanFriendlyRulesRequest {
515609
option deprecated = true;
@@ -591,7 +685,8 @@ message ListRulesRequest {
591685
string page_token = 2 [(google.api.field_behavior) = OPTIONAL];
592686

593687
// A [Common Expression Language (CEL)](https://github.com/google/cel-spec) filter string.
594-
// Available fields to filter by are `rule_id`, `client_key`, `name`, `description`, `asset_id`, `tag_id`, and `deleted_date`.
688+
// Available fields to filter by are `rule_id`, `client_key`, `name`, `description`, `is_external`, `asset_id`, `tag_id`,
689+
// `created_date`, `created_by_user_id`, `modified_date`, `modified_by_user_id`, `deleted_date`, `is_archived`, and `archived_date`.
595690
// For further information about how to use CELs, please refer to [this guide](https://github.com/google/cel-spec/blob/master/doc/langdef.md#standard-definitions).
596691
// Optional.
597692
string filter = 3 [(google.api.field_behavior) = OPTIONAL];
@@ -636,7 +731,15 @@ message RuleVersion {
636731
string created_by_user_id = 5 [(google.api.field_behavior) = REQUIRED];
637732
string version_notes = 6 [(google.api.field_behavior) = REQUIRED];
638733
string generated_change_message = 7 [(google.api.field_behavior) = REQUIRED];
639-
google.protobuf.Timestamp deleted_date = 8 [(google.api.field_behavior) = OPTIONAL];
734+
google.protobuf.Timestamp deleted_date = 8 [
735+
(google.api.field_behavior) = OPTIONAL,
736+
deprecated = true
737+
];
738+
// archived_date indicates when the rule version was archived
739+
google.protobuf.Timestamp archived_date = 9 [(google.api.field_behavior) = OPTIONAL];
740+
741+
// is_archived is inferred from when archived_date is not null
742+
bool is_archived = 10 [(google.api.field_behavior) = REQUIRED];
640743
}
641744

642745
message ListRuleVersionsResponse {

0 commit comments

Comments
 (0)