Skip to content

Commit

Permalink
fix flaky test with timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
opauloh committed Oct 9, 2024
1 parent a31b16e commit a492d7c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe('CreateDetectionRuleFromVulnerability', () => {
} as Vulnerability;
const currentTimestamp = new Date().toISOString();

const query = generateVulnerabilitiesRuleQuery(mockVulnerability);
const query = generateVulnerabilitiesRuleQuery(mockVulnerability, currentTimestamp);
expect(query).toEqual(
`vulnerability.id: "CVE-2024-00005" AND event.ingested >= "${currentTimestamp}"`
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ export const getVulnerabilityRuleName = (vulnerability: Vulnerability) => {
});
};

export const generateVulnerabilitiesRuleQuery = (vulnerability: Vulnerability) => {
const currentTimestamp = new Date().toISOString();

return `vulnerability.id: "${vulnerability.id}" AND event.ingested >= "${currentTimestamp}"`;
export const generateVulnerabilitiesRuleQuery = (
vulnerability: Vulnerability,
startTimestamp = new Date().toISOString()
) => {
return `vulnerability.id: "${vulnerability.id}" AND event.ingested >= "${startTimestamp}"`;
};

const CSP_RULE_TAG = 'Cloud Security';
Expand Down

0 comments on commit a492d7c

Please sign in to comment.