Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add text selector #426

Merged
merged 1 commit into from
Jan 23, 2025
Merged

feat: Add text selector #426

merged 1 commit into from
Jan 23, 2025

Conversation

e-fisher
Copy link
Collaborator

@e-fisher e-fisher commented Jan 22, 2025

Description

Add text selector to exact string match replacements. Previously you'd have to use a workaround with regex selector: regex: (value_to_be_placed).

This selector applies to parameterization rule and correlation rule custom replacer, but not correlation extractor, because it doesn't make sense to correlate on static value.

How to Test

  • Test with parameterization rule: try both "text value" and "variable" replacement
  • Test with custom replacer in correlation rule

Checklist

  • I have performed a self-review of my code.
  • I have added tests for my changes.
  • I have run linter locally (npm run lint) and all checks pass.
  • I have run tests locally (npm test) and all tests pass.
  • I have commented on my code, particularly in hard-to-understand areas.

Screenshots (if appropriate):

screencapture 2025-01-22 at 11 25 14

Related PR(s)/Issue(s)

Resolves #315

@@ -25,3 +31,32 @@ export function replaceCorrelatedValues({
value: varName,
})
}

function replaceAllTextMatches(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move function here from shared.ts because it's the only place where it's used.

Comment on lines +81 to +86
export const ExtractorSelectorSchema = z.discriminatedUnion('type', [
BeginEndSelectorSchema,
RegexSelectorSchema,
JsonSelectorSchema,
HeaderNameSelectorSchema,
])
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split Selector schema into Extractor and Replacer, because Text selector doesn't apply to extractions

@e-fisher e-fisher marked this pull request as ready for review January 22, 2025 09:29
@e-fisher e-fisher requested a review from a team as a code owner January 22, 2025 09:29
Copy link
Collaborator

@cristianoventura cristianoventura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🎸

Copy link
Member

@Llandy3d Llandy3d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@e-fisher e-fisher merged commit f1e6826 into main Jan 23, 2025
4 checks passed
@e-fisher e-fisher deleted the feat/add-text-selector branch January 23, 2025 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Selectors: Text entry for constant values
3 participants