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

Refactor escape sequence handling #822

Merged
merged 1 commit into from
Jan 25, 2024
Merged

Conversation

adhilto
Copy link
Collaborator

@adhilto adhilto commented Jan 19, 2024

🗣 Description

This PR makes it so that ScubaGear no longer attempts to remove all backslashes, only the specific character sequences known to cause problems for Rego.

💭 Motivation and context

The provider output can include characters that Rego attempts to interpret as escape sequences (such as \/, which is output when you convert a date to json in PowerShell 5 (e.g., Get-Date | Convert-ToJson). These sequences result in the error "unable to parse input: yaml: line x: found unknown escape character." Previously, ScubaGear attempted to circumvent this issue by wholesale removing all backslashes from the resulting json. However, there are cases where that technique resulted in broken json (see #807 and #770).

Closes #818.

🧪 Testing

Tested on the E5, G3, G5, and GCCHigh tenants, asserting that the number of tests passing/failing matched for both this branch and main. Also, engineered a problematic transport rule that would cause a parsing error as described in #807 (comment). That rule causes the parsing error in main but not this branch.

✅ Pre-approval checklist

  • This PR has an informative and human-readable title.
  • PR targets the correct parent branch (e.g., main or release-name) for merge.
  • Changes are limited to a single goal - eschew scope creep!
  • Changes are sized such that they do not touch excessive number of files.
  • All future TODOs are captured in issues, which are referenced in code comments.
  • These code changes follow the ScubaGear content style guide.
  • Related issues these changes resolve are linked preferably via closing keywords.
  • All relevant type-of-change labels added.
  • All relevant project fields are set.
  • All relevant repo and/or project documentation updated to reflect these changes.
  • Unit tests added/updated to cover PowerShell and Rego changes.
  • Functional tests added/updated to cover PowerShell and Rego changes.
  • All relevant functional tests passed.
  • All automated checks (e.g., linting, static analysis, unit/smoke tests) passed.

✅ Pre-merge checklist

  • PR passed smoke test check.

  • Feature branch has been rebased against changes from parent branch, as needed

    Use Rebase branch button below or use this reference to rebase from the command line.

  • Resolved all merge conflicts on branch

  • Notified merge coordinator that PR is ready for merge via comment mention

✅ Post-merge checklist

  • Feature branch deleted after merge to clean up repository.
  • Verified that all checks pass on parent branch (e.g., main or release-name) after merge.

@adhilto adhilto added the bug This issue or pull request addresses broken functionality label Jan 19, 2024
@adhilto adhilto added this to the Flipper milestone Jan 19, 2024
@adhilto adhilto self-assigned this Jan 19, 2024
@adhilto adhilto linked an issue Jan 19, 2024 that may be closed by this pull request
Copy link
Contributor

@crutchfield crutchfield left a comment

Choose a reason for hiding this comment

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

Ran Scuba against all products and review reports. Verified ProviderSettingExport has no back slashes.

Copy link
Collaborator

@schrolla schrolla left a comment

Choose a reason for hiding this comment

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

Just had one question about the update to escaping based on the Date example. See below.

Copy link
Collaborator

@schrolla schrolla left a comment

Choose a reason for hiding this comment

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

Changes look good and all testing works as expected.

@adhilto
Copy link
Collaborator Author

adhilto commented Jan 24, 2024

@nanda-katikaneni this PR is ready to go.

@schrolla schrolla force-pushed the 818-json-parsing-fix branch from c5064ed to fd329da Compare January 25, 2024 16:26
@nanda-katikaneni nanda-katikaneni merged commit 2f6b048 into main Jan 25, 2024
4 checks passed
@nanda-katikaneni nanda-katikaneni deleted the 818-json-parsing-fix branch January 25, 2024 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue or pull request addresses broken functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provider Json Parsing Broken Edge Case
4 participants