Skip to content

Commit

Permalink
Remove source_updated_at from rule schema
Browse files Browse the repository at this point in the history
We need to coordinate this addition with the TRaDE team
(elastic/detection-rules#2826).
  • Loading branch information
rylnd committed Sep 5, 2024
1 parent c433c92 commit 554f340
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ export const KqlQueryLanguageEnum = KqlQueryLanguage.enum;
export type IsRuleImmutable = z.infer<typeof IsRuleImmutable>;
export const IsRuleImmutable = z.boolean();

/**
* The date and time that the external/prebuilt rule was last updated in its source repository.
*/
export type ExternalSourceUpdatedAt = z.infer<typeof ExternalSourceUpdatedAt>;
export const ExternalSourceUpdatedAt = z.string().datetime();

/**
* Determines whether an external/prebuilt rule has been customized by the user (i.e. any of its fields have been modified and diverged from the base value).
*/
Expand All @@ -84,7 +78,6 @@ export type ExternalRuleSource = z.infer<typeof ExternalRuleSource>;
export const ExternalRuleSource = z.object({
type: z.literal('external'),
is_customized: IsExternalRuleCustomized,
source_updated_at: ExternalSourceUpdatedAt.optional(),
});

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ components:
deprecated: true
description: '[DEPRECATION WARNING TODO] - This field determines whether the rule is a prebuilt Elastic rule. It will be replaced with the `rule_source` field.'

ExternalSourceUpdatedAt:
type: string
format: date-time
example: '2021-08-31T00:00:00Z'
description: The date and time that the external/prebuilt rule was last updated in its source repository.

IsExternalRuleCustomized:
type: boolean
description: Determines whether an external/prebuilt rule has been customized by the user (i.e. any of its fields have been modified and diverged from the base value).
Expand All @@ -76,8 +70,6 @@ components:
- external
is_customized:
$ref: '#/components/schemas/IsExternalRuleCustomized'
source_updated_at:
$ref: '#/components/schemas/ExternalSourceUpdatedAt'
required:
- type
- is_customized
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2968,22 +2968,13 @@ components:
properties:
is_customized:
$ref: '#/components/schemas/IsExternalRuleCustomized'
source_updated_at:
$ref: '#/components/schemas/ExternalSourceUpdatedAt'
type:
enum:
- external
type: string
required:
- type
- is_customized
ExternalSourceUpdatedAt:
description: >-
The date and time that the external/prebuilt rule was last updated in
its source repository.
example: '2021-08-31T00:00:00Z'
format: date-time
type: string
FindRulesSortField:
enum:
- created_at
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2242,22 +2242,13 @@ components:
properties:
is_customized:
$ref: '#/components/schemas/IsExternalRuleCustomized'
source_updated_at:
$ref: '#/components/schemas/ExternalSourceUpdatedAt'
type:
enum:
- external
type: string
required:
- type
- is_customized
ExternalSourceUpdatedAt:
description: >-
The date and time that the external/prebuilt rule was last updated in
its source repository.
example: '2021-08-31T00:00:00Z'
format: date-time
type: string
FindRulesSortField:
enum:
- created_at
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ function zodMaskFor<T>() {
* Big differences between this schema and RuleCreateProps:
* - rule_id is a required field
* - version is a required field
* - source_updated_at is a new, optional field in support of prebuilt rule customization
* - some fields are omitted because they are not present in https://github.com/elastic/detection-rules
*/
export type PrebuiltRuleAsset = z.infer<typeof PrebuiltRuleAsset>;
Expand All @@ -82,6 +81,5 @@ export const PrebuiltRuleAsset = BaseCreateProps.omit(BASE_PROPS_REMOVED_FROM_PR
z.object({
rule_id: RuleSignatureId,
version: RuleVersion,
source_updated_at: z.string().datetime().optional(),
})
);
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const buildTestRuleAsset = (overrides?: Partial<PrebuiltRuleAsset>) => {
return {
rule_id: 'rule_id',
version: 1,
source_updated_at: '2024-05-01',
...overrides,
} as PrebuiltRuleAsset;
};
Expand Down Expand Up @@ -76,7 +75,6 @@ describe('calculateRuleSourceFromAsset', () => {

expect(result).toEqual({
type: 'external',
source_updated_at: '2024-05-01',
is_customized: true,
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,5 @@ export const calculateRuleSourceFromAsset = ({
return {
type: 'external',
is_customized: isCustomized,
source_updated_at: prebuiltRuleAsset.source_updated_at,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const buildTestRuleAsset = (overrides?: Partial<PrebuiltRuleAsset>) => {
return {
rule_id: 'rule_id',
version: 1,
source_updated_at: '2024-05-01',
...overrides,
} as PrebuiltRuleAsset;
};
Expand Down Expand Up @@ -64,7 +63,6 @@ describe('calculateRuleSourceForImport', () => {

expect(result).toEqual({
type: 'external',
source_updated_at: '2024-05-01',
isCustomized: true,
});
});
Expand Down

0 comments on commit 554f340

Please sign in to comment.