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

tech story: [M3-8423] - Resolve "Incomplete string escape or encoding" in generate-ansibleConfig.test.ts #10887

Merged
merged 4 commits into from
Sep 10, 2024

Conversation

coliu-akamai
Copy link
Contributor

@coliu-akamai coliu-akamai commented Sep 4, 2024

Description πŸ“

  • Resolve codeQL alert due to not escaping backslashes by updating regex
  • Added test case for the special characters not yet tested for

Target release date πŸ—“οΈ

n/a

Preview πŸ“·

Before After
image image

How to test πŸ§ͺ

Prerequisites

Here are the steps I took to setup codeQL on vscode. Not sure if this is the most straightforward way, but it (seems to have) worked πŸ˜…

  • download the codeQL extension on vscode
  • follow along to this guide
    • I used the most up to date version (2.18.3) when downloading codeQL CLI this time around, but I remember using the version listed in the guide for a prior ticket, and that had worked too. (I believe VS code also automatically updates the CLI to v2.18.3 for you if you use the guide's version - ty @mjac0bs!)
    • You don't actually need the vscode extension if you follow this guide to completion. I stopped after the creating a database portion and just used the extension from there. Run the create database command in the manager/src/utilities/codesnippets package - I had trouble when trying to create a database with the entirety of manager
  • Open up codeql-repo (naming conventions from the guide ^) in vscode, click on the QL tab in the sidebar, and select the database you just created
    image

Verification steps

  • run the IncompleteSanitization.ql query and confirm warning is gone (codeql-repo >> javascript >> ql >> src >> Security >> CWE-116 >> IncompleteSanitization.ql)
    image

  • NOTE if you want to run this query on both develop (to see the warning) and this branch (to confirm it's gone), you will need to create DBs for both develop and this branch...the DB does not automatically update

As an Author I have considered πŸ€”

Check all that apply

  • πŸ‘€ Doing a self review
  • ❔ Our contribution guidelines
  • 🀏 Splitting feature into small PRs
  • βž• Adding a changeset
  • πŸ§ͺ Providing/Improving test coverage
  • πŸ” Removing all sensitive information from the code and PR description
  • 🚩 Using a feature flag to protect the release
  • πŸ‘£ Providing comprehensive reproduction steps
  • πŸ“‘ Providing or updating our documentation
  • πŸ•› Scheduling a pair reviewing session
  • πŸ“± Providing mobile support
  • β™Ώ Providing accessibility support

@coliu-akamai coliu-akamai self-assigned this Sep 4, 2024
@coliu-akamai coliu-akamai marked this pull request as ready for review September 4, 2024 16:32
@coliu-akamai coliu-akamai requested a review from a team as a code owner September 4, 2024 16:32
@coliu-akamai coliu-akamai requested review from cpathipa and hkhalil-akamai and removed request for a team September 4, 2024 16:32

it('should safely escape extra backslash characters in YAML strings', () => {
const config = {
label: 'Linode with ] and also \\[, }, and \\{',
Copy link
Contributor Author

@coliu-akamai coliu-akamai Sep 4, 2024

Choose a reason for hiding this comment

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

note: Originally I'd had \] and \} in this label, but eslint corrected them to just ] and { πŸ₯²... They still resulted in \\] and \\}, same as the current expected output (which is good/what we'd want, I think!).

Copy link

github-actions bot commented Sep 4, 2024

Coverage Report: βœ…
Base Coverage: 86.2%
Current Coverage: 86.21%

@mjac0bs mjac0bs self-requested a review September 6, 2024 19:27
Copy link
Contributor

@mjac0bs mjac0bs left a comment

Choose a reason for hiding this comment

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

Thank you for the thorough instructions! (The need to create a second db thing was a great call out too.) Confirmed the error is resolved on this branch - and thank you for the test. πŸš€

develop this branch
Screenshot 2024-09-06 at 12 56 08β€―PM Screenshot 2024-09-06 at 1 03 02β€―PM

@mjac0bs mjac0bs added the Add'tl Approval Needed Waiting on another approval! label Sep 6, 2024
Copy link
Contributor

@hkhalil-akamai hkhalil-akamai left a comment

Choose a reason for hiding this comment

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

Thanks for linking the setup instructions. Verified the code scanning error is gone.

Edit: failing test seems unrelated -- retrying.

@coliu-akamai coliu-akamai added Approved Multiple approvals and ready to merge! and removed Add'tl Approval Needed Waiting on another approval! labels Sep 10, 2024
@coliu-akamai coliu-akamai merged commit 4aab482 into linode:develop Sep 10, 2024
19 checks passed
@coliu-akamai coliu-akamai deleted the m3-8423 branch October 9, 2024 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved Multiple approvals and ready to merge! Ready for Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants