File tree 2 files changed +124
-0
lines changed
2 files changed +124
-0
lines changed Original file line number Diff line number Diff line change
1
+ // CAMARA Project - support function for Spectral linter
2
+ // 31.01.2024 - initial version
3
+
4
+ const reservedWords = [
5
+ 'abstract' ,
6
+ 'apiclient' ,
7
+ 'apiexception' ,
8
+ 'apiresponse' ,
9
+ 'assert' ,
10
+ 'boolean' ,
11
+ 'break' ,
12
+ 'byte' ,
13
+ 'case' ,
14
+ 'catch' ,
15
+ 'char' ,
16
+ 'class' ,
17
+ 'configuration' ,
18
+ 'const' ,
19
+ 'continue' ,
20
+ 'do' ,
21
+ 'double' ,
22
+ 'else' ,
23
+ 'extends' ,
24
+ 'file' ,
25
+ 'final' ,
26
+ 'finally' ,
27
+ 'float' ,
28
+ 'for' ,
29
+ 'goto' ,
30
+ 'if' ,
31
+ 'implements' ,
32
+ 'import' ,
33
+ 'instanceof' ,
34
+ 'int' ,
35
+ 'interface' ,
36
+ 'list' ,
37
+ 'localdate' ,
38
+ 'localreturntype' ,
39
+ 'localtime' ,
40
+ 'localvaraccept' ,
41
+ 'localvaraccepts' ,
42
+ 'localvarauthnames' ,
43
+ 'localvarcollectionqueryparams' ,
44
+ 'localvarcontenttype' ,
45
+ 'localvarcontenttypes' ,
46
+ 'localvarcookieparams' ,
47
+ 'localvarformparams' ,
48
+ 'localvarheaderparams' ,
49
+ 'localvarpath' ,
50
+ 'localvarpostbody' ,
51
+ 'localvarqueryparams' ,
52
+ 'long' ,
53
+ 'native' ,
54
+ 'new' ,
55
+ 'null' ,
56
+ 'object' ,
57
+ 'offsetdatetime' ,
58
+ 'package' ,
59
+ 'private' ,
60
+ 'protected' ,
61
+ 'public' ,
62
+ 'return' ,
63
+ 'short' ,
64
+ 'static' ,
65
+ 'strictfp' ,
66
+ 'stringutil' ,
67
+ 'super' ,
68
+ 'switch' ,
69
+ 'synchronized' ,
70
+ 'this' ,
71
+ 'throw' ,
72
+ 'throws' ,
73
+ 'transient' ,
74
+ 'try' ,
75
+ 'void' ,
76
+ 'volatile' ,
77
+ 'while'
78
+ ] ;
79
+ // Reserved word 'enum' and 'default' are removed from above reserved word array as they are common in openAPI keyword
80
+ export default async function lintReservedWords ( input ) {
81
+ // Iterate over properties of the input object
82
+ for ( const path in input ) {
83
+ if ( typeof path === 'string' ) {
84
+
85
+ for ( const word of reservedWords ) {
86
+ const regex = new RegExp ( `\\b${ word } \\b` , 'g' ) ; // Use a regular expression to match 'word' as a standalone word
87
+
88
+ if ( regex . test ( path ) ) {
89
+ const warningRuleName = 'camara-reserved-words' ;
90
+ const description = `Reserved words found in input: Consider avoiding the use of reserved word '${ word } '` ;
91
+ // const location = `${path}`;
92
+
93
+ console . log ( `warning ${ warningRuleName } ${ description } ${ path } ` ) ;
94
+ }
95
+ }
96
+ }
97
+ }
98
+ }
Original file line number Diff line number Diff line change
1
+ // CAMARA Project - support function for Spectral linter
2
+ // 31.01.2024 - initial version
3
+
4
+ const sensitiveData = [ 'MSISDN' , 'IMSI' , 'phoneNumber' ] ;
5
+
6
+ export default async function ( input ) {
7
+
8
+ // Iterate over properties of the input object
9
+ for ( const path in input ) {
10
+
11
+ if ( typeof path === 'string' ) {
12
+ for ( const word of sensitiveData ) {
13
+ const regex = new RegExp ( `\\b${ word } \\b` , 'g' ) ; // Use a regular expression to match 'word' as a standalone word
14
+
15
+ if ( regex . test ( path ) ) {
16
+
17
+ const warningRuleName = 'camara-security-no-secrets-in-path-or-query-parameters' ;
18
+ const description = `sensitiveData Data found in path: Consider avoiding the use of sensitiveData data '${ word } '` ;
19
+ const location = `paths.${ path } ` ;
20
+ console . log ( `warning ${ warningRuleName } ${ description } ${ location } ` ) ;
21
+
22
+ }
23
+ }
24
+ }
25
+ }
26
+ }
You can’t perform that action at this time.
0 commit comments