Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

test: quotes are escaped#432

Closed
sezanzeb wants to merge 1 commit into
influxdata:masterinfluxdata/influxdb-client-js:masterfrom
sezanzeb:mastersezanzeb/influxdb-client-js:masterCopy head branch name to clipboard
Closed

test: quotes are escaped#432
sezanzeb wants to merge 1 commit into
influxdata:masterinfluxdata/influxdb-client-js:masterfrom
sezanzeb:mastersezanzeb/influxdb-client-js:masterCopy head branch name to clipboard

Conversation

@sezanzeb

@sezanzeb sezanzeb commented Apr 8, 2022

Copy link
Copy Markdown

Proposed Changes

Just adds a single test. I was investigating how to use flux but couldn't see if this escapes and prevents injection attacks.

Checklist

  • CHANGELOG.md updated < I guess adding a test isn't really something worth mentioning there
  • Rebased/mergeable < I guess so?
  • A test has been added if appropriate
  • yarn test completes successfully
  • Commit messages are in semantic format
  • Sign CLA (if not already signed) < Dude, just take it or leave it. I'm not interested in spending an hour trying to decipher this legal lingo for this. I don't care about having any rights about those 8 lines of code or whatever. I give this to you.

@sezanzeb sezanzeb changed the title added test to check if quotes are escaped @sezanzeb test: quotes are escaped Apr 8, 2022
@sezanzeb sezanzeb changed the title @sezanzeb test: quotes are escaped test: quotes are escaped Apr 8, 2022
@sranka
sranka self-requested a review April 8, 2022 18:27

@sranka sranka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank @sezanzeb you for a PR, but I think that your changes do not bring any additional value to this library. The flux tagged template is designed exactly for the purpose that you double-checked, it is properly documented this way in https://influxdata.github.io/influxdb-client-js/influxdb-client.flux.html . All the possible value types and escape sequences are already tested thoroughly in flux.test.ts. A possible (but not a necessary improvement) would be to add

        if (pair.value !== undefined) {
          expect(flux`${pair.value}`.toString()).equals(pair.flux)
        } else {
          expect(() => flux`${pair.value}`.toString()).to.throw(
            "Unsupported parameter literal 'undefined' at index: 0, type: undefined"
          )
        }

right after

https://github.com/influxdata/influxdb-client-js/blob/master/packages/core/test/unit/query/flux.test.ts#L119

it will then extra test all parameter types and escape sequences within the flux tagged template.

@sezanzeb

sezanzeb commented Apr 8, 2022

Copy link
Copy Markdown
Author

The only test that uses doubles quotes in flux is:

  it('processes a simple nested flux template', () => {
    const flux1 = flux`from(bucket:"my-bucket")`
    expect(flux`${flux1} |> range(start: ${0})")`.toString()).equals(
      'from(bucket:"my-bucket") |> range(start: 0)")'
    )
  })

but it is different. The new test that I added tries to insert a string containing a double-quote into another set of double-quotes in the target. There is no test that expects an escaped double-quote: \"

or what am I missing here?

There just isn't a test that makes sure that a user-defined string (like foo"bar) is not breaking the command

@sranka

sranka commented Apr 9, 2022

Copy link
Copy Markdown
Contributor

Thank you for your feedback.

@sranka sranka closed this Apr 9, 2022
@bednar bednar added this to the 1.25.0 milestone Apr 14, 2022
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.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.