Skip to content

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

Merged
coliu-akamai merged 4 commits intolinode:developfrom
coliu-akamai:m3-8423
Sep 10, 2024
Merged

tech story: [M3-8423] - Resolve "Incomplete string escape or encoding" in generate-ansibleConfig.test.ts#10887
coliu-akamai merged 4 commits intolinode:developfrom
coliu-akamai:m3-8423

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!).

@github-actions
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
@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

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants