Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
frontend/utilities/node-sql-parser
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ website/
# certain frontend files that are not meant to be formatted
frontend/components/FleetAce/mode.ts
frontend/components/FleetAce/theme.ts
frontend/utilities/node-sql-parser

# github workflow yaml, which may contain shell scripts that shouldn't be formatted
.github/workflows/*
1 change: 1 addition & 0 deletions changes/30109-fix-sql-like-clause
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fixed an issue where using ESCAPE in a LIKE clause caused SQL validation to fail
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Parser } from "node-sql-parser";
import { Parser } from "utilities/node-sql-parser/sqlite";
import { includes, some } from "lodash";

const invalidQueryResponse = (message) => {
Expand Down
12 changes: 12 additions & 0 deletions frontend/utilities/node-sql-parser/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# About

This is compiled from a [fork](https://github.com/taozhi8833998/node-sql-parser/compare/master...sgress454:node-sql-parser:5.3.10-plus) of the 5.3.10 release of [node-sql-parser library](https://github.com/sgress454/node-sql-parser/tree/sgress454/add-escape-to-sqlite-like) created to fix issue [#30109](https://github.com/fleetdm/fleet/issues/30109).

Once a new release of node-sql-parser comes out with this code in it, we can revert back to using `node-sql-parser` as a dependency in Fleet.

# To compile

1. Check out https://github.com/sgress454/node-sql-parser/tree/5.3.10-plus
2. `npm install`
3. `npm run build`
4. `cp output/prod/build/sqlite.* /path/to/fleet/frontend/utilities/node-sql-parser`
1 change: 1 addition & 0 deletions frontend/utilities/node-sql-parser/sqlite.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '../types';
2 changes: 2 additions & 0 deletions frontend/utilities/node-sql-parser/sqlite.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions frontend/utilities/node-sql-parser/sqlite.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion frontend/utilities/sql_tools.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { checkTable } from "./sql_tools";

describe("checkTable", () => {
// from https://github.com/fleetdm/fleet/issues/26366
// and https://github.com/fleetdm/fleet/issues/30109
const SQL = `
WITH extension_safety_hub_menu_notifications AS (
SELECT
Expand Down Expand Up @@ -42,7 +43,7 @@ SELECT path,
timestamp,
triggering_extension
FROM problematic_extensions
WHERE triggering_extension IS NOT NULL;
WHERE triggering_extension IS NOT NULL AND username NOT LIKE '\\_%' ESCAPE '\\';
`;
it("should return only real tables by default", () => {
const { tables, error } = checkTable(SQL);
Expand Down
2 changes: 1 addition & 1 deletion frontend/utilities/sql_tools.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore
import { Parser } from "node-sql-parser";
import { Parser } from "utilities/node-sql-parser/sqlite";
import { intersection, isPlainObject, uniq } from "lodash";
import { osqueryTablesAvailable } from "utilities/osquery_tables";
import {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"js-yaml": "3.14.1",
"lodash": "4.17.21",
"memoize-one": "5.2.1",
"node-sql-parser": "5.3.8",
"normalizr": "3.6.2",
"prop-types": "15.8.1",
"proxy-middleware": "0.15.0",
Expand Down
18 changes: 0 additions & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3677,11 +3677,6 @@
resolved "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz"
integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==

"@types/pegjs@^0.10.0":
version "0.10.6"
resolved "https://registry.yarnpkg.com/@types/pegjs/-/pegjs-0.10.6.tgz#bc20fc4809fed4cddab8d0dbee0e568803741a82"
integrity sha512-eLYXDbZWXh2uxf+w8sXS8d6KSoXTswfps6fvCUuVAGN8eRpfe7h9eSRydxiSJvo9Bf+GzifsDOr9TMQlmJdmkw==

"@types/prettier@^2.1.5":
version "2.7.1"
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.7.1.tgz#dfd20e2dc35f027cdd6c1908e80a5ddc7499670e"
Expand Down Expand Up @@ -4884,11 +4879,6 @@ big-integer@^1.6.16:
resolved "https://registry.npmjs.org/big-integer/-/big-integer-1.6.51.tgz"
integrity sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==

big-integer@^1.6.48:
version "1.6.52"
resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.52.tgz#60a887f3047614a8e1bffe5d7173490a97dc8c85"
integrity sha512-QxD8cf2eVqJOOz63z6JIN9BzvVs/dlySa5HGSBH5xtR8dPteIRQnBxxKqkNTiT6jbDTF6jAfrd4oMcND9RGbQg==

big.js@^5.2.2:
version "5.2.2"
resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328"
Expand Down Expand Up @@ -10858,14 +10848,6 @@ node-sass-magic-importer@^5.3.3:
postcss-scss "^3.0.2"
resolve "^1.17.0"

node-sql-parser@5.3.8:
version "5.3.8"
resolved "https://registry.yarnpkg.com/node-sql-parser/-/node-sql-parser-5.3.8.tgz#b71db4cb80dc5302fc77d7b6ca3bcb269b2124bf"
integrity sha512-aqGTzK8kPJAwQ6tqdS0l+vX358LXMmZDw902ePfiPn3PSDsg2HeR2tHFioXNHJW00YHoic6VVYY80waFb/zdxw==
dependencies:
"@types/pegjs" "^0.10.0"
big-integer "^1.6.48"

normalize-path@^3.0.0, normalize-path@~3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65"
Expand Down
Loading