grafeo-ogm 1.7.2 → 1.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/README.md +2 -0
  3. package/dist/cjs/compilers/fulltext.compiler.d.ts.map +1 -1
  4. package/dist/cjs/compilers/fulltext.compiler.js +30 -7
  5. package/dist/cjs/compilers/fulltext.compiler.js.map +1 -1
  6. package/dist/cjs/compilers/mutation.compiler.d.ts.map +1 -1
  7. package/dist/cjs/compilers/mutation.compiler.js +80 -1
  8. package/dist/cjs/compilers/mutation.compiler.js.map +1 -1
  9. package/dist/cjs/compilers/vector.compiler.js +13 -1
  10. package/dist/cjs/compilers/vector.compiler.js.map +1 -1
  11. package/dist/cjs/execution/result-mapper.d.ts.map +1 -1
  12. package/dist/cjs/execution/result-mapper.js +8 -2
  13. package/dist/cjs/execution/result-mapper.js.map +1 -1
  14. package/dist/cjs/interface-model.d.ts.map +1 -1
  15. package/dist/cjs/interface-model.js +58 -7
  16. package/dist/cjs/interface-model.js.map +1 -1
  17. package/dist/cjs/model.d.ts.map +1 -1
  18. package/dist/cjs/model.js +37 -6
  19. package/dist/cjs/model.js.map +1 -1
  20. package/dist/cjs/utils/lucene.d.ts +12 -3
  21. package/dist/cjs/utils/lucene.d.ts.map +1 -1
  22. package/dist/cjs/utils/lucene.js +28 -13
  23. package/dist/cjs/utils/lucene.js.map +1 -1
  24. package/dist/esm/compilers/fulltext.compiler.d.ts.map +1 -1
  25. package/dist/esm/compilers/fulltext.compiler.js +30 -7
  26. package/dist/esm/compilers/fulltext.compiler.js.map +1 -1
  27. package/dist/esm/compilers/mutation.compiler.d.ts.map +1 -1
  28. package/dist/esm/compilers/mutation.compiler.js +80 -1
  29. package/dist/esm/compilers/mutation.compiler.js.map +1 -1
  30. package/dist/esm/compilers/vector.compiler.js +13 -1
  31. package/dist/esm/compilers/vector.compiler.js.map +1 -1
  32. package/dist/esm/execution/result-mapper.d.ts.map +1 -1
  33. package/dist/esm/execution/result-mapper.js +8 -2
  34. package/dist/esm/execution/result-mapper.js.map +1 -1
  35. package/dist/esm/interface-model.d.ts.map +1 -1
  36. package/dist/esm/interface-model.js +59 -8
  37. package/dist/esm/interface-model.js.map +1 -1
  38. package/dist/esm/model.d.ts.map +1 -1
  39. package/dist/esm/model.js +37 -6
  40. package/dist/esm/model.js.map +1 -1
  41. package/dist/esm/utils/lucene.d.ts +12 -3
  42. package/dist/esm/utils/lucene.d.ts.map +1 -1
  43. package/dist/esm/utils/lucene.js +28 -13
  44. package/dist/esm/utils/lucene.js.map +1 -1
  45. package/package.json +1 -1
@@ -1,9 +1,18 @@
1
1
  /**
2
2
  * Escapes special Lucene characters in a query string.
3
- * Special characters: + - && || ! ( ) { } [ ] ^ " ~ * ? : \ /
4
3
  *
5
- * Handles multi-character operators (&&, ||) as atomic units,
6
- * then escapes remaining individual special characters.
4
+ * Symbol-form operators escaped:
5
+ * + - && || ! ( ) { } [ ] ^ " ~ * ? : \ /
6
+ *
7
+ * Bareword booleans (`AND`, `OR`, `NOT`, `TO`) are also neutralised. Pre-
8
+ * 1.7.3 they survived sanitisation, letting an attacker inject a boolean
9
+ * query (e.g. `foo AND _exists_:adminFlag`) even after symbol escaping.
10
+ * The standard Lucene analyser lowercases tokens during indexing, so
11
+ * lowercasing the bareword turns it into a literal-word match — which
12
+ * is what callers of `sanitizeLuceneQuery` expect (the function exists
13
+ * to make untrusted user input safe to pass to Lucene). Range-modifier
14
+ * boost/fuzzy (`^N`, `~N`) are already disarmed because `^` and `~`
15
+ * get backslash-escaped in the symbol pass.
7
16
  */
8
17
  export declare function sanitizeLuceneQuery(query: string): string;
9
18
  //# sourceMappingURL=lucene.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lucene.d.ts","sourceRoot":"","sources":["../../../src/utils/lucene.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAgBzD"}
1
+ {"version":3,"file":"lucene.d.ts","sourceRoot":"","sources":["../../../src/utils/lucene.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAyBzD"}
@@ -1,22 +1,37 @@
1
1
  /**
2
2
  * Escapes special Lucene characters in a query string.
3
- * Special characters: + - && || ! ( ) { } [ ] ^ " ~ * ? : \ /
4
3
  *
5
- * Handles multi-character operators (&&, ||) as atomic units,
6
- * then escapes remaining individual special characters.
4
+ * Symbol-form operators escaped:
5
+ * + - && || ! ( ) { } [ ] ^ " ~ * ? : \ /
6
+ *
7
+ * Bareword booleans (`AND`, `OR`, `NOT`, `TO`) are also neutralised. Pre-
8
+ * 1.7.3 they survived sanitisation, letting an attacker inject a boolean
9
+ * query (e.g. `foo AND _exists_:adminFlag`) even after symbol escaping.
10
+ * The standard Lucene analyser lowercases tokens during indexing, so
11
+ * lowercasing the bareword turns it into a literal-word match — which
12
+ * is what callers of `sanitizeLuceneQuery` expect (the function exists
13
+ * to make untrusted user input safe to pass to Lucene). Range-modifier
14
+ * boost/fuzzy (`^N`, `~N`) are already disarmed because `^` and `~`
15
+ * get backslash-escaped in the symbol pass.
7
16
  */
8
17
  export function sanitizeLuceneQuery(query) {
9
- // First pass: escape multi-char operators as atomic units
10
- // Use placeholders to prevent double-escaping by the second pass
11
- let result = query
12
- .replace(/&&/g, '\u0000AND\u0000')
13
- .replace(/\|\|/g, '\u0000OR\u0000');
14
- // Second pass: escape individual special characters (& and | individually)
18
+ // FIRST pass: neutralise bareword booleans BEFORE the placeholder dance
19
+ // below. Running this last would let user-typed " AND " / " OR " collide
20
+ // with the restoration regex (which matches those exact tokens) and
21
+ // wrongly rewrite literal user words to escaped `\&\&` / `\|\|`. Running
22
+ // this first turns user `foo AND bar` into `foo and bar` (literal-word
23
+ // match) before any other pass sees it. Word boundaries (`\b`) keep us
24
+ // from touching middle-of-word matches like `BAND` or `STOP`.
25
+ let result = query.replace(/\b(AND|OR|NOT|TO)\b/g, (match) => match.toLowerCase());
26
+ // Second pass: escape multi-char operators as atomic units. We use
27
+ // " AND " / " OR " as placeholders (rather than NULL bytes) because
28
+ // the lowercase pass above guarantees no user-typed uppercase " AND "
29
+ // / " OR " can survive to collide with the restoration regex below.
30
+ result = result.replace(/&&/g, ' AND ').replace(/\|\|/g, ' OR ');
31
+ // Third pass: escape individual special characters (& and | individually)
15
32
  result = result.replace(/([+\-&|!(){}[\]^"~*?:\\/])/g, '\\$1');
16
- // Restore multi-char operators with proper escaping
17
- result = result
18
- .replace(/\u0000AND\u0000/g, '\\&\\&')
19
- .replace(/\u0000OR\u0000/g, '\\|\\|');
33
+ // Fourth pass: restore multi-char operators with proper escaping
34
+ result = result.replace(/ AND /g, '\\&\\&').replace(/ OR /g, '\\|\\|');
20
35
  return result;
21
36
  }
22
37
  //# sourceMappingURL=lucene.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lucene.js","sourceRoot":"","sources":["../../../src/utils/lucene.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAC/C,0DAA0D;IAC1D,iEAAiE;IACjE,IAAI,MAAM,GAAG,KAAK;SACf,OAAO,CAAC,KAAK,EAAE,iBAAiB,CAAC;SACjC,OAAO,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;IAEtC,2EAA2E;IAC3E,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC;IAE/D,oDAAoD;IACpD,MAAM,GAAG,MAAM;SACZ,OAAO,CAAC,kBAAkB,EAAE,QAAQ,CAAC;SACrC,OAAO,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;IAExC,OAAO,MAAM,CAAC;AAChB,CAAC"}
1
+ {"version":3,"file":"lucene.js","sourceRoot":"","sources":["../../../src/utils/lucene.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAC/C,wEAAwE;IACxE,yEAAyE;IACzE,oEAAoE;IACpE,yEAAyE;IACzE,uEAAuE;IACvE,uEAAuE;IACvE,8DAA8D;IAC9D,IAAI,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,sBAAsB,EAAE,CAAC,KAAK,EAAE,EAAE,CAC3D,KAAK,CAAC,WAAW,EAAE,CACpB,CAAC;IAEF,mEAAmE;IACnE,oEAAoE;IACpE,sEAAsE;IACtE,oEAAoE;IACpE,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAEjE,0EAA0E;IAC1E,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC;IAE/D,iEAAiE;IACjE,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAEvE,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grafeo-ogm",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
4
4
  "description": "Type-safe Neo4j ORM / OGM for TypeScript. Define your graph in GraphQL SDL, get fully typed Prisma-like CRUD, optimized Cypher, and zero-config code generation. Community successor to @neo4j/graphql-ogm.",
5
5
  "license": "MIT",
6
6
  "author": "Alejandro Guzman",