clear-your-tools 0.0.1__tar.gz
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.
- clear_your_tools-0.0.1/.ast-grep/rule-tests/.gitkeep +0 -0
- clear_your_tools-0.0.1/.ast-grep/rule-tests/Test.md +3 -0
- clear_your_tools-0.0.1/.ast-grep/rules/.gitkeep +0 -0
- clear_your_tools-0.0.1/.ast-grep/rules/Lint.md +12 -0
- clear_your_tools-0.0.1/.ast-grep/rules/avoid-nested-links-tsx.yml +8 -0
- clear_your_tools-0.0.1/.ast-grep/rules/find-import-file-without-extension-ts.yml +17 -0
- clear_your_tools-0.0.1/.ast-grep/rules/missing-component-decorator-ts.yml +26 -0
- clear_your_tools-0.0.1/.ast-grep/rules/no-await-in-promise-all-ts.yml +9 -0
- clear_your_tools-0.0.1/.ast-grep/rules/no-console-except-catch-ts.yml +9 -0
- clear_your_tools-0.0.1/.ast-grep/rules/rewrite-mobx-component-tsx.yml +7 -0
- clear_your_tools-0.0.1/.ast-grep/rules/security-detect-angular-sce-disabled-js.yml +18 -0
- clear_your_tools-0.0.1/.ast-grep/rules/security-detect-angular-sce-disabled-ts.yml +38 -0
- clear_your_tools-0.0.1/.ast-grep/rules/security-express-session-hardcoded-secret-js.yml +106 -0
- clear_your_tools-0.0.1/.ast-grep/rules/security-express-session-hardcoded-secret-ts.yml +207 -0
- clear_your_tools-0.0.1/.ast-grep/rules/security-jwt-simple-noverify-js.yml +45 -0
- clear_your_tools-0.0.1/.ast-grep/rules/security-jwt-simple-noverify-ts.yml +116 -0
- clear_your_tools-0.0.1/.ast-grep/rules/security-node-rsa-weak-key-js.yml +581 -0
- clear_your_tools-0.0.1/.ast-grep/rules/security-node-rsa-weak-key-ts.yml +1490 -0
- clear_your_tools-0.0.1/.ast-grep/rules/security-node-sequelize-empty-password-argument-js.yml +195 -0
- clear_your_tools-0.0.1/.ast-grep/rules/security-node-sequelize-empty-password-argument-ts.yml +173 -0
- clear_your_tools-0.0.1/.ast-grep/rules/security-node-sequelize-hardcoded-secret-argument-js.yml +97 -0
- clear_your_tools-0.0.1/.ast-grep/rules/security-node-sequelize-hardcoded-secret-argument-ts.yml +158 -0
- clear_your_tools-0.0.1/.ast-grep/rules/security-plaintext-http-link-html.yml +78 -0
- clear_your_tools-0.0.1/.ast-grep/rules/securityexpress-jwt-hardcoded-secret-js.yml +295 -0
- clear_your_tools-0.0.1/.ast-grep/rules/speed-up-barrel-import-ts.yml +22 -0
- clear_your_tools-0.0.1/.ast-grep/rules/upgrade-ant-design-vue-html.yml +24 -0
- clear_your_tools-0.0.1/.ast-grep/utils/.gitkeep +0 -0
- clear_your_tools-0.0.1/.env.example +2 -0
- clear_your_tools-0.0.1/.github/workflows/ci.yml +42 -0
- clear_your_tools-0.0.1/.github/workflows/publish-pypi.yml +56 -0
- clear_your_tools-0.0.1/.gitignore +90 -0
- clear_your_tools-0.0.1/.gitmodules +6 -0
- clear_your_tools-0.0.1/.markdownlint-cli2.yaml +13 -0
- clear_your_tools-0.0.1/.markdownlintignore +2 -0
- clear_your_tools-0.0.1/.osgrepignore +10 -0
- clear_your_tools-0.0.1/.pre-commit-config.yaml +192 -0
- clear_your_tools-0.0.1/.python-version +1 -0
- clear_your_tools-0.0.1/LICENSE +201 -0
- clear_your_tools-0.0.1/PKG-INFO +395 -0
- clear_your_tools-0.0.1/README.md +354 -0
- clear_your_tools-0.0.1/Taskfile.yml +12 -0
- clear_your_tools-0.0.1/count_request_tokens.py +48 -0
- clear_your_tools-0.0.1/package-lock.json +163 -0
- clear_your_tools-0.0.1/package.json +5 -0
- clear_your_tools-0.0.1/pyproject.toml +239 -0
- clear_your_tools-0.0.1/requirements.txt +1398 -0
- clear_your_tools-0.0.1/search/claude.sh +11 -0
- clear_your_tools-0.0.1/search/proxy.sh +9 -0
- clear_your_tools-0.0.1/src/__init__.py +0 -0
- clear_your_tools-0.0.1/src/cyt/__init__.py +3 -0
- clear_your_tools-0.0.1/src/cyt/common/__init__.py +1 -0
- clear_your_tools-0.0.1/src/cyt/common/catalog_paths.py +68 -0
- clear_your_tools-0.0.1/src/cyt/common/pricing.py +222 -0
- clear_your_tools-0.0.1/src/cyt/common/token_usage.py +41 -0
- clear_your_tools-0.0.1/src/cyt/config/__init__.py +471 -0
- clear_your_tools-0.0.1/src/cyt/config/defaults.yaml +94 -0
- clear_your_tools-0.0.1/src/cyt/indexer/__init__.py +30 -0
- clear_your_tools-0.0.1/src/cyt/indexer/build.py +431 -0
- clear_your_tools-0.0.1/src/cyt/indexer/catalog_io.py +109 -0
- clear_your_tools-0.0.1/src/cyt/indexer/retrieve.py +455 -0
- clear_your_tools-0.0.1/src/cyt/proxy/__init__.py +1 -0
- clear_your_tools-0.0.1/src/cyt/proxy/anthropic.py +845 -0
- clear_your_tools-0.0.1/src/cyt/proxy/cli.py +213 -0
- clear_your_tools-0.0.1/src/cyt/proxy/reverse.py +818 -0
- clear_your_tools-0.0.1/src/cyt/proxy/stats.py +590 -0
- clear_your_tools-0.0.1/src/cyt/proxy/transport.py +188 -0
- clear_your_tools-0.0.1/src/cyt/pruners/__init__.py +11 -0
- clear_your_tools-0.0.1/src/cyt/pruners/llm.py +456 -0
- clear_your_tools-0.0.1/src/cyt/pruners/policies.py +799 -0
- clear_your_tools-0.0.1/src/cyt/pruners/rerank.py +446 -0
- clear_your_tools-0.0.1/src/cyt/pruners/split.py +74 -0
- clear_your_tools-0.0.1/src/cyt/py.typed +0 -0
- clear_your_tools-0.0.1/src/tests/test_configs.py +108 -0
- clear_your_tools-0.0.1/src/tests/test_db.py +117 -0
- clear_your_tools-0.0.1/src/tests/test_empty_optional_properties.py +262 -0
- clear_your_tools-0.0.1/src/tests/test_proxy_anthropic.py +231 -0
- clear_your_tools-0.0.1/src/tests/test_tool_policies.py +161 -0
- clear_your_tools-0.0.1/src/tests/test_tool_policies_pass_through.py +29 -0
- clear_your_tools-0.0.1/typings/brotli.pyi +1 -0
- clear_your_tools-0.0.1/typings/libsql_experimental/__init__.pyi +10 -0
- clear_your_tools-0.0.1/typos.toml +6 -0
- clear_your_tools-0.0.1/uv.lock +2160 -0
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Lint Rule
|
|
2
|
+
|
|
3
|
+
<https://github.com/ast-grep/ast-grep.github.io/blob/main/website/guide/project/lint-rule.md>
|
|
4
|
+
|
|
5
|
+
## Rule Catalog
|
|
6
|
+
|
|
7
|
+
<https://github.com/ast-grep/ast-grep.github.io/tree/main/website/catalog/python>
|
|
8
|
+
<https://github.com/ast-grep/ast-grep.github.io/tree/main/website/catalog/yaml>
|
|
9
|
+
<https://github.com/ast-grep/ast-grep.github.io/tree/main/website/catalog/typescript>
|
|
10
|
+
<https://github.com/ast-grep/ast-grep.github.io/tree/main/website/catalog/html>
|
|
11
|
+
|
|
12
|
+
<https://github.com/coderabbitai/ast-grep-essentials/tree/main/rules>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
id: find-import-file
|
|
2
|
+
message: Local file imports should include file extensions (.ts, .js, etc). Exclude npm packages.
|
|
3
|
+
language: js
|
|
4
|
+
severity: info
|
|
5
|
+
rule:
|
|
6
|
+
regex: "^\\./[^.]+[^/]$"
|
|
7
|
+
kind: string_fragment
|
|
8
|
+
any:
|
|
9
|
+
- inside:
|
|
10
|
+
stopBy: end
|
|
11
|
+
kind: import_statement
|
|
12
|
+
- inside:
|
|
13
|
+
stopBy: end
|
|
14
|
+
kind: call_expression
|
|
15
|
+
has:
|
|
16
|
+
field: function
|
|
17
|
+
regex: "^import$"
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
id: missing-component-decorator
|
|
2
|
+
message: You're using an Angular lifecycle method, but missing an Angular @Component() decorator.
|
|
3
|
+
language: TypeScript
|
|
4
|
+
severity: warning
|
|
5
|
+
rule:
|
|
6
|
+
pattern:
|
|
7
|
+
context: "class Hi { $METHOD() { $$$_} }"
|
|
8
|
+
selector: method_definition
|
|
9
|
+
inside:
|
|
10
|
+
pattern: "class $KLASS $$$_ { $$$_ }"
|
|
11
|
+
stopBy: end
|
|
12
|
+
not:
|
|
13
|
+
has:
|
|
14
|
+
pattern: "@Component($$$_)"
|
|
15
|
+
constraints:
|
|
16
|
+
METHOD:
|
|
17
|
+
regex: ngOnInit|ngOnDestroy
|
|
18
|
+
labels:
|
|
19
|
+
KLASS:
|
|
20
|
+
style: primary
|
|
21
|
+
message: "This class is missing the decorator."
|
|
22
|
+
METHOD:
|
|
23
|
+
style: secondary
|
|
24
|
+
message: "This is an Angular lifecycle method."
|
|
25
|
+
metadata:
|
|
26
|
+
contributedBy: samwightt
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
id: no-console-except-error
|
|
2
|
+
message: Avoid console.log or console.debug in production code. Use console.error for errors or logging.warn for warnings. (Test files in __tests__/ are allowed.)
|
|
3
|
+
language: typescript
|
|
4
|
+
severity: warning
|
|
5
|
+
rule:
|
|
6
|
+
pattern: console.$METHOD($$$)
|
|
7
|
+
constraints:
|
|
8
|
+
METHOD:
|
|
9
|
+
regex: "log|debug"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
id: detect-angular-sce-disabled-javascript
|
|
2
|
+
language: javascript
|
|
3
|
+
severity: warning
|
|
4
|
+
message: >-
|
|
5
|
+
$sceProvider is set to false. Disabling Strict Contextual escaping
|
|
6
|
+
(SCE) in an AngularJS application could provide additional attack surface
|
|
7
|
+
for XSS vulnerabilities.
|
|
8
|
+
note: >-
|
|
9
|
+
[CWE-79] Improper Neutralization of Input During Web Page Generation.
|
|
10
|
+
[REFERENCES]
|
|
11
|
+
- https://docs.angularjs.org/api/ng/service/$sce
|
|
12
|
+
- https://owasp.org/www-chapter-london/assets/slides/OWASPLondon20170727_AngularJS.pdf
|
|
13
|
+
|
|
14
|
+
ast-grep-essentials: true
|
|
15
|
+
|
|
16
|
+
rule:
|
|
17
|
+
pattern: |
|
|
18
|
+
$sceProvider.enabled(false);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
id: detect-angular-sce-disabled-typescript
|
|
2
|
+
language: typescript
|
|
3
|
+
severity: warning
|
|
4
|
+
message: >-
|
|
5
|
+
$sceProvider is set to false. Disabling Strict Contextual escaping
|
|
6
|
+
(SCE) in an AngularJS application could provide additional attack surface
|
|
7
|
+
for XSS vulnerabilities.
|
|
8
|
+
note: >-
|
|
9
|
+
[CWE-79] Improper Neutralization of Input During Web Page Generation.
|
|
10
|
+
[REFERENCES]
|
|
11
|
+
- https://docs.angularjs.org/api/ng/service/$sce
|
|
12
|
+
- https://owasp.org/www-chapter-london/assets/slides/OWASPLondon20170727_AngularJS.pdf
|
|
13
|
+
ast-grep-essentials: true
|
|
14
|
+
rule:
|
|
15
|
+
kind: expression_statement
|
|
16
|
+
regex: ^\$sceProvider
|
|
17
|
+
has:
|
|
18
|
+
kind: call_expression
|
|
19
|
+
stopBy: end
|
|
20
|
+
all:
|
|
21
|
+
- has:
|
|
22
|
+
kind: member_expression
|
|
23
|
+
nthChild: 1
|
|
24
|
+
all:
|
|
25
|
+
- has:
|
|
26
|
+
kind: identifier
|
|
27
|
+
regex: ^\$sceProvider$
|
|
28
|
+
- has:
|
|
29
|
+
kind: property_identifier
|
|
30
|
+
regex: ^enabled$
|
|
31
|
+
precedes:
|
|
32
|
+
kind: arguments
|
|
33
|
+
has:
|
|
34
|
+
kind: "false"
|
|
35
|
+
nthChild: 1
|
|
36
|
+
not:
|
|
37
|
+
has:
|
|
38
|
+
nthChild: 2
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
id: express-session-hardcoded-secret-javascript
|
|
2
|
+
language: javascript
|
|
3
|
+
severity: warning
|
|
4
|
+
message: >-
|
|
5
|
+
A hard-coded credential was detected. It is not recommended to store
|
|
6
|
+
credentials in source-code, as this risks secrets being leaked and used by
|
|
7
|
+
either an internal or external malicious adversary. It is recommended to
|
|
8
|
+
use environment variables to securely provide credentials or retrieve
|
|
9
|
+
credentials from a secure vault or HSM (Hardware Security Module).
|
|
10
|
+
note: >-
|
|
11
|
+
[CWE-798] Use of Hard-coded Credentials.
|
|
12
|
+
[REFERENCES]
|
|
13
|
+
- https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html
|
|
14
|
+
ast-grep-essentials: true
|
|
15
|
+
utils:
|
|
16
|
+
MATCH_SECRET:
|
|
17
|
+
kind: pair
|
|
18
|
+
pattern: $C
|
|
19
|
+
inside:
|
|
20
|
+
stopBy: end
|
|
21
|
+
kind: lexical_declaration
|
|
22
|
+
all:
|
|
23
|
+
- has:
|
|
24
|
+
stopBy: end
|
|
25
|
+
kind: variable_declarator
|
|
26
|
+
has:
|
|
27
|
+
stopBy: end
|
|
28
|
+
kind: object
|
|
29
|
+
has:
|
|
30
|
+
stopBy: end
|
|
31
|
+
kind: pair
|
|
32
|
+
pattern: $C
|
|
33
|
+
all:
|
|
34
|
+
- has:
|
|
35
|
+
stopBy: end
|
|
36
|
+
kind: property_identifier
|
|
37
|
+
pattern: $S
|
|
38
|
+
- has:
|
|
39
|
+
stopBy: end
|
|
40
|
+
kind: string
|
|
41
|
+
has:
|
|
42
|
+
stopBy: end
|
|
43
|
+
kind: string_fragment
|
|
44
|
+
|
|
45
|
+
- follows:
|
|
46
|
+
stopBy: end
|
|
47
|
+
kind: import_statement
|
|
48
|
+
any:
|
|
49
|
+
- pattern: import session from 'express'
|
|
50
|
+
- pattern: import session from 'express-session'
|
|
51
|
+
- pattern: import {session} from 'express-session'
|
|
52
|
+
- pattern: import * as session from 'express-session'
|
|
53
|
+
MATCH_SECRET_with_Instance:
|
|
54
|
+
kind: pair
|
|
55
|
+
all:
|
|
56
|
+
- has:
|
|
57
|
+
stopBy: neighbor
|
|
58
|
+
kind: property_identifier
|
|
59
|
+
regex: ^secret$
|
|
60
|
+
- has:
|
|
61
|
+
stopBy: neighbor
|
|
62
|
+
kind: identifier
|
|
63
|
+
pattern: $SECRET
|
|
64
|
+
- inside:
|
|
65
|
+
stopBy: end
|
|
66
|
+
kind: expression_statement
|
|
67
|
+
follows:
|
|
68
|
+
stopBy: end
|
|
69
|
+
kind: lexical_declaration
|
|
70
|
+
has:
|
|
71
|
+
stopBy: end
|
|
72
|
+
kind: variable_declarator
|
|
73
|
+
all:
|
|
74
|
+
- has:
|
|
75
|
+
stopBy: neighbor
|
|
76
|
+
kind: identifier
|
|
77
|
+
pattern: $SECRET
|
|
78
|
+
- has:
|
|
79
|
+
stopBy: neighbor
|
|
80
|
+
kind: string
|
|
81
|
+
has:
|
|
82
|
+
stopBy: neighbor
|
|
83
|
+
kind: string_fragment
|
|
84
|
+
- inside:
|
|
85
|
+
stopBy: end
|
|
86
|
+
any:
|
|
87
|
+
- kind: lexical_declaration
|
|
88
|
+
- kind: expression_statement
|
|
89
|
+
follows:
|
|
90
|
+
stopBy: end
|
|
91
|
+
kind: import_statement
|
|
92
|
+
any:
|
|
93
|
+
- pattern: import session from 'express'
|
|
94
|
+
- pattern: import session from 'express-session'
|
|
95
|
+
- pattern: import {session} from 'express-session'
|
|
96
|
+
- pattern: import * as session from 'express-session'
|
|
97
|
+
|
|
98
|
+
rule:
|
|
99
|
+
kind: pair
|
|
100
|
+
any:
|
|
101
|
+
- matches: MATCH_SECRET
|
|
102
|
+
- matches: MATCH_SECRET_with_Instance
|
|
103
|
+
|
|
104
|
+
constraints:
|
|
105
|
+
S:
|
|
106
|
+
regex: "^secret$"
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
id: express-session-hardcoded-secret-typescript
|
|
2
|
+
language: typescript
|
|
3
|
+
severity: warning
|
|
4
|
+
message: >-
|
|
5
|
+
A hard-coded credential was detected. It is not recommended to store
|
|
6
|
+
credentials in source-code, as this risks secrets being leaked and used by
|
|
7
|
+
either an internal or external malicious adversary. It is recommended to
|
|
8
|
+
use environment variables to securely provide credentials or retrieve
|
|
9
|
+
credentials from a secure vault or HSM (Hardware Security Module).
|
|
10
|
+
note: >-
|
|
11
|
+
[CWE-798] Use of Hard-coded Credentials.
|
|
12
|
+
[REFERENCES]
|
|
13
|
+
- https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html
|
|
14
|
+
ast-grep-essentials: true
|
|
15
|
+
rule:
|
|
16
|
+
kind: pair
|
|
17
|
+
all:
|
|
18
|
+
- has:
|
|
19
|
+
kind: property_identifier
|
|
20
|
+
regex: ^secret$
|
|
21
|
+
nthChild: 1
|
|
22
|
+
- has:
|
|
23
|
+
kind: string
|
|
24
|
+
nthChild: 2
|
|
25
|
+
inside:
|
|
26
|
+
stopBy: end
|
|
27
|
+
kind: object
|
|
28
|
+
pattern: $OBJECT
|
|
29
|
+
any:
|
|
30
|
+
- inside:
|
|
31
|
+
stopBy: end
|
|
32
|
+
kind: call_expression
|
|
33
|
+
pattern: $APP.use($SESSION($OBJECT))
|
|
34
|
+
inside:
|
|
35
|
+
stopBy: end
|
|
36
|
+
follows:
|
|
37
|
+
stopBy: end
|
|
38
|
+
any:
|
|
39
|
+
- kind: import_statement
|
|
40
|
+
all:
|
|
41
|
+
- has:
|
|
42
|
+
kind: import_clause
|
|
43
|
+
any:
|
|
44
|
+
- has:
|
|
45
|
+
kind: namespace_import
|
|
46
|
+
has:
|
|
47
|
+
kind: identifier
|
|
48
|
+
pattern: $SESSION
|
|
49
|
+
- has:
|
|
50
|
+
kind: named_imports
|
|
51
|
+
has:
|
|
52
|
+
kind: import_specifier
|
|
53
|
+
pattern: $SESSION
|
|
54
|
+
- has:
|
|
55
|
+
kind: identifier
|
|
56
|
+
pattern: $SESSION
|
|
57
|
+
- has:
|
|
58
|
+
kind: string
|
|
59
|
+
nthChild: 2
|
|
60
|
+
regex: ^'express-session'$
|
|
61
|
+
- any:
|
|
62
|
+
- kind: lexical_declaration
|
|
63
|
+
all:
|
|
64
|
+
- has:
|
|
65
|
+
kind: variable_declarator
|
|
66
|
+
all:
|
|
67
|
+
- has:
|
|
68
|
+
kind: identifier
|
|
69
|
+
pattern: $SESSION
|
|
70
|
+
nthChild: 1
|
|
71
|
+
- has:
|
|
72
|
+
kind: call_expression
|
|
73
|
+
nthChild: 2
|
|
74
|
+
regex: ^require\('express-session'\)$
|
|
75
|
+
- kind: expression_statement
|
|
76
|
+
has:
|
|
77
|
+
kind: assignment_expression
|
|
78
|
+
all:
|
|
79
|
+
- has:
|
|
80
|
+
kind: identifier
|
|
81
|
+
pattern: $SESSION
|
|
82
|
+
nthChild: 1
|
|
83
|
+
- has:
|
|
84
|
+
kind: call_expression
|
|
85
|
+
nthChild: 2
|
|
86
|
+
regex: ^require\('express-session'\)$
|
|
87
|
+
|
|
88
|
+
- inside:
|
|
89
|
+
stopBy: end
|
|
90
|
+
|
|
91
|
+
any:
|
|
92
|
+
- kind: lexical_declaration
|
|
93
|
+
- any:
|
|
94
|
+
- kind: expression_statement
|
|
95
|
+
- kind: assignment_expression
|
|
96
|
+
not:
|
|
97
|
+
follows:
|
|
98
|
+
kind: ERROR
|
|
99
|
+
- kind: variable_declaration
|
|
100
|
+
has:
|
|
101
|
+
stopBy: end
|
|
102
|
+
any:
|
|
103
|
+
- kind: variable_declarator
|
|
104
|
+
- kind: assignment_expression
|
|
105
|
+
has:
|
|
106
|
+
kind: identifier
|
|
107
|
+
pattern: $IDENTIFIER
|
|
108
|
+
any:
|
|
109
|
+
- precedes:
|
|
110
|
+
stopBy: end
|
|
111
|
+
kind: object
|
|
112
|
+
pattern: $OBJECT
|
|
113
|
+
- precedes:
|
|
114
|
+
stopBy: end
|
|
115
|
+
has:
|
|
116
|
+
stopBy: end
|
|
117
|
+
kind: object
|
|
118
|
+
pattern: $OBJECT
|
|
119
|
+
- inside:
|
|
120
|
+
stopBy: end
|
|
121
|
+
precedes:
|
|
122
|
+
stopBy: end
|
|
123
|
+
has:
|
|
124
|
+
stopBy: end
|
|
125
|
+
kind: object
|
|
126
|
+
pattern: $OBJECT
|
|
127
|
+
precedes:
|
|
128
|
+
stopBy: end
|
|
129
|
+
has:
|
|
130
|
+
stopBy: end
|
|
131
|
+
kind: call_expression
|
|
132
|
+
pattern: $APP.use($SESSION($IDENTIFIER))
|
|
133
|
+
has:
|
|
134
|
+
stopBy: end
|
|
135
|
+
kind: identifier
|
|
136
|
+
pattern: $IDENTIFIER
|
|
137
|
+
inside:
|
|
138
|
+
stopBy: end
|
|
139
|
+
follows:
|
|
140
|
+
stopBy: end
|
|
141
|
+
any:
|
|
142
|
+
- kind: import_statement
|
|
143
|
+
all:
|
|
144
|
+
- has:
|
|
145
|
+
kind: import_clause
|
|
146
|
+
any:
|
|
147
|
+
- has:
|
|
148
|
+
kind: namespace_import
|
|
149
|
+
has:
|
|
150
|
+
kind: identifier
|
|
151
|
+
pattern: $SESSION
|
|
152
|
+
- has:
|
|
153
|
+
kind: named_imports
|
|
154
|
+
has:
|
|
155
|
+
kind: import_specifier
|
|
156
|
+
pattern: $SESSION
|
|
157
|
+
- has:
|
|
158
|
+
kind: identifier
|
|
159
|
+
pattern: $SESSION
|
|
160
|
+
- has:
|
|
161
|
+
kind: string
|
|
162
|
+
nthChild: 2
|
|
163
|
+
regex: ^'express-session'$
|
|
164
|
+
- any:
|
|
165
|
+
- any:
|
|
166
|
+
- kind: lexical_declaration
|
|
167
|
+
- kind: variable_declaration
|
|
168
|
+
all:
|
|
169
|
+
- has:
|
|
170
|
+
kind: variable_declarator
|
|
171
|
+
all:
|
|
172
|
+
- has:
|
|
173
|
+
kind: identifier
|
|
174
|
+
pattern: $SESSION
|
|
175
|
+
nthChild: 1
|
|
176
|
+
- has:
|
|
177
|
+
kind: call_expression
|
|
178
|
+
nthChild: 2
|
|
179
|
+
all:
|
|
180
|
+
- has:
|
|
181
|
+
nthChild: 1
|
|
182
|
+
kind: identifier
|
|
183
|
+
regex: ^require$
|
|
184
|
+
- has:
|
|
185
|
+
nthChild: 2
|
|
186
|
+
kind: arguments
|
|
187
|
+
regex: ^\('express-session'\)$
|
|
188
|
+
- kind: expression_statement
|
|
189
|
+
has:
|
|
190
|
+
kind: assignment_expression
|
|
191
|
+
all:
|
|
192
|
+
- has:
|
|
193
|
+
kind: identifier
|
|
194
|
+
pattern: $SESSION
|
|
195
|
+
nthChild: 1
|
|
196
|
+
- has:
|
|
197
|
+
kind: call_expression
|
|
198
|
+
nthChild: 2
|
|
199
|
+
all:
|
|
200
|
+
- has:
|
|
201
|
+
nthChild: 1
|
|
202
|
+
kind: identifier
|
|
203
|
+
regex: ^require$
|
|
204
|
+
- has:
|
|
205
|
+
nthChild: 2
|
|
206
|
+
kind: arguments
|
|
207
|
+
regex: ^\('express-session'\)$
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
id: jwt-simple-noverify-javascript
|
|
2
|
+
language: JavaScript
|
|
3
|
+
severity: warning
|
|
4
|
+
message: >-
|
|
5
|
+
"Detected the decoding of a JWT token without a verify step. JWT tokens
|
|
6
|
+
must be verified before use, otherwise the token's integrity is unknown.
|
|
7
|
+
This means a malicious actor could forge a JWT token with any claims. Set
|
|
8
|
+
'verify' to `true` before using the token."
|
|
9
|
+
note: >-
|
|
10
|
+
[CWE-287] Improper Authentication
|
|
11
|
+
[CWE-345] Insufficient Verification of Data Authenticity
|
|
12
|
+
[CWE-347] Improper Verification of Cryptographic Signature
|
|
13
|
+
[REFERENCES]
|
|
14
|
+
- https://www.npmjs.com/package/jwt-simple
|
|
15
|
+
- https://cwe.mitre.org/data/definitions/287
|
|
16
|
+
- https://cwe.mitre.org/data/definitions/345
|
|
17
|
+
- https://cwe.mitre.org/data/definitions/347
|
|
18
|
+
ast-grep-essentials: true
|
|
19
|
+
rule:
|
|
20
|
+
kind: call_expression
|
|
21
|
+
any:
|
|
22
|
+
- pattern: $JWT.decode($TOKEN, $SECRET, true $$$)
|
|
23
|
+
- pattern: $JWT.decode($TOKEN, $SECRET, "$$$" $$$)
|
|
24
|
+
- pattern: $JWT.decode($TOKEN, $SECRET, '$$$' $$$)
|
|
25
|
+
- pattern: $JWT.decode($TOKEN, $SECRET, `$$$` $$$)
|
|
26
|
+
inside:
|
|
27
|
+
stopBy: end
|
|
28
|
+
follows:
|
|
29
|
+
stopBy: end
|
|
30
|
+
any:
|
|
31
|
+
- kind: lexical_declaration
|
|
32
|
+
all:
|
|
33
|
+
- has:
|
|
34
|
+
stopBy: end
|
|
35
|
+
kind: identifier
|
|
36
|
+
pattern: $JWT
|
|
37
|
+
- has:
|
|
38
|
+
stopBy: end
|
|
39
|
+
kind: call_expression
|
|
40
|
+
pattern: require('jwt-simple')
|
|
41
|
+
- kind: expression_statement
|
|
42
|
+
has:
|
|
43
|
+
stopBy: end
|
|
44
|
+
kind: assignment_expression
|
|
45
|
+
pattern: $JWT = require('jwt-simple')
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
id: jwt-simple-noverify-typescript
|
|
2
|
+
language: TypeScript
|
|
3
|
+
severity: warning
|
|
4
|
+
message: >-
|
|
5
|
+
"Detected the decoding of a JWT token without a verify step. JWT tokens
|
|
6
|
+
must be verified before use, otherwise the token's integrity is unknown.
|
|
7
|
+
This means a malicious actor could forge a JWT token with any claims. Set
|
|
8
|
+
'verify' to `true` before using the token."
|
|
9
|
+
note: >-
|
|
10
|
+
[CWE-287] Improper Authentication
|
|
11
|
+
[CWE-345] Insufficient Verification of Data Authenticity
|
|
12
|
+
[CWE-347] Improper Verification of Cryptographic Signature
|
|
13
|
+
[REFERENCES]
|
|
14
|
+
- https://www.npmjs.com/package/jwt-simple
|
|
15
|
+
- https://cwe.mitre.org/data/definitions/287
|
|
16
|
+
- https://cwe.mitre.org/data/definitions/345
|
|
17
|
+
- https://cwe.mitre.org/data/definitions/347
|
|
18
|
+
ast-grep-essentials: true
|
|
19
|
+
rule:
|
|
20
|
+
pattern: $JWT.decode($TOKEN, $SECRET, $NOVERIFY $$$)
|
|
21
|
+
inside:
|
|
22
|
+
stopBy: end
|
|
23
|
+
follows:
|
|
24
|
+
stopBy: end
|
|
25
|
+
any:
|
|
26
|
+
- any:
|
|
27
|
+
- kind: lexical_declaration
|
|
28
|
+
- kind: variable_declaration
|
|
29
|
+
all:
|
|
30
|
+
- has:
|
|
31
|
+
kind: variable_declarator
|
|
32
|
+
all:
|
|
33
|
+
- has:
|
|
34
|
+
kind: identifier
|
|
35
|
+
pattern: $JWT
|
|
36
|
+
nthChild: 1
|
|
37
|
+
- has:
|
|
38
|
+
kind: call_expression
|
|
39
|
+
nthChild: 2
|
|
40
|
+
all:
|
|
41
|
+
- has:
|
|
42
|
+
nthChild: 1
|
|
43
|
+
kind: identifier
|
|
44
|
+
regex: ^require$
|
|
45
|
+
- has:
|
|
46
|
+
nthChild: 2
|
|
47
|
+
kind: arguments
|
|
48
|
+
has:
|
|
49
|
+
stopBy: end
|
|
50
|
+
kind: string
|
|
51
|
+
nthChild: 1
|
|
52
|
+
has:
|
|
53
|
+
kind: string_fragment
|
|
54
|
+
regex: ^jwt-simple$
|
|
55
|
+
all:
|
|
56
|
+
- not:
|
|
57
|
+
has:
|
|
58
|
+
nthChild: 2
|
|
59
|
+
- not:
|
|
60
|
+
has:
|
|
61
|
+
stopBy: end
|
|
62
|
+
any:
|
|
63
|
+
- kind: object
|
|
64
|
+
- kind: array
|
|
65
|
+
- kind: pair
|
|
66
|
+
|
|
67
|
+
- kind: expression_statement
|
|
68
|
+
has:
|
|
69
|
+
kind: assignment_expression
|
|
70
|
+
all:
|
|
71
|
+
- has:
|
|
72
|
+
kind: identifier
|
|
73
|
+
pattern: $JWT
|
|
74
|
+
nthChild: 1
|
|
75
|
+
- has:
|
|
76
|
+
kind: call_expression
|
|
77
|
+
nthChild: 2
|
|
78
|
+
all:
|
|
79
|
+
- has:
|
|
80
|
+
nthChild: 1
|
|
81
|
+
kind: identifier
|
|
82
|
+
regex: ^require$
|
|
83
|
+
- has:
|
|
84
|
+
nthChild: 2
|
|
85
|
+
kind: arguments
|
|
86
|
+
has:
|
|
87
|
+
stopBy: end
|
|
88
|
+
kind: string
|
|
89
|
+
has:
|
|
90
|
+
kind: string_fragment
|
|
91
|
+
regex: ^jwt-simple$
|
|
92
|
+
|
|
93
|
+
constraints:
|
|
94
|
+
NOVERIFY:
|
|
95
|
+
all:
|
|
96
|
+
- any:
|
|
97
|
+
- any:
|
|
98
|
+
- regex: ^true$
|
|
99
|
+
- kind: string
|
|
100
|
+
- kind: template_string
|
|
101
|
+
- has:
|
|
102
|
+
stopBy: end
|
|
103
|
+
any:
|
|
104
|
+
- regex: ^true$
|
|
105
|
+
- kind: string
|
|
106
|
+
- kind: template_string
|
|
107
|
+
not:
|
|
108
|
+
any:
|
|
109
|
+
- kind: property_identifier
|
|
110
|
+
- kind: shorthand_property_identifier
|
|
111
|
+
- any:
|
|
112
|
+
- kind: string
|
|
113
|
+
- kind: template_string
|
|
114
|
+
nthChild: 1
|
|
115
|
+
inside:
|
|
116
|
+
kind: pair
|