@pb33f/cowboy-components 0.1.16 → 0.2.0

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 (74) hide show
  1. package/dist/assets/rule-documentation.worker-D39NS8Lx.js +1 -0
  2. package/dist/components/editor/editor.d.ts +2 -0
  3. package/dist/components/editor/editor.js +6 -4
  4. package/dist/components/error-banner/error-banner.css.js +1 -1
  5. package/dist/components/manage-ruleset/function-option.css.d.ts +2 -0
  6. package/dist/components/manage-ruleset/function-option.css.js +38 -0
  7. package/dist/components/manage-ruleset/function-option.d.ts +19 -0
  8. package/dist/components/manage-ruleset/function-option.js +117 -0
  9. package/dist/components/manage-ruleset/manage-ruleset.css.d.ts +2 -0
  10. package/dist/components/manage-ruleset/manage-ruleset.css.js +75 -0
  11. package/dist/components/manage-ruleset/manage-ruleset.d.ts +62 -0
  12. package/dist/components/manage-ruleset/manage-ruleset.js +575 -0
  13. package/dist/components/manage-ruleset/rule-action.css.d.ts +2 -0
  14. package/dist/components/manage-ruleset/rule-action.css.js +56 -0
  15. package/dist/components/manage-ruleset/rule-action.d.ts +37 -0
  16. package/dist/components/manage-ruleset/rule-action.js +351 -0
  17. package/dist/components/manage-ruleset/rule-input.d.ts +38 -0
  18. package/dist/components/manage-ruleset/rule-input.js +296 -0
  19. package/dist/components/manage-ruleset/rule.css.d.ts +2 -0
  20. package/dist/components/manage-ruleset/rule.css.js +117 -0
  21. package/dist/components/manage-ruleset/rule.d.ts +31 -0
  22. package/dist/components/manage-ruleset/rule.js +153 -0
  23. package/dist/components/problem-list/details-drawer.d.ts +2 -1
  24. package/dist/components/problem-list/details-drawer.js +7 -0
  25. package/dist/components/problem-list/filter.css.js +2 -3
  26. package/dist/components/problem-list/problem-item.css.js +1 -3
  27. package/dist/components/problem-list/problem-item.js +1 -1
  28. package/dist/components/problem-list/problem-list.css.js +0 -10
  29. package/dist/components/problem-list/problem-list.js +0 -1
  30. package/dist/components/problems-overview/document-statistic.css.js +0 -1
  31. package/dist/components/problems-overview/problem-overview-group.css.js +1 -3
  32. package/dist/components/problems-overview/problem-overview-group.js +2 -2
  33. package/dist/components/problems-overview/problem-statistics.css.js +0 -5
  34. package/dist/components/problems-overview/problems-overview.css.js +0 -4
  35. package/dist/components/the-doctor/the-doctor.css.js +99 -27
  36. package/dist/components/the-doctor/the-doctor.d.ts +65 -8
  37. package/dist/components/the-doctor/the-doctor.js +663 -63
  38. package/dist/components/toast/toast-component.css.d.ts +2 -0
  39. package/dist/components/toast/toast-component.css.js +151 -0
  40. package/dist/components/toast/toast-component.d.ts +19 -0
  41. package/dist/components/toast/toast-component.js +116 -0
  42. package/dist/components/toast/toast-manager.d.ts +13 -0
  43. package/dist/components/toast/toast-manager.js +54 -0
  44. package/dist/cowboy-components.umd.cjs +1375 -372
  45. package/dist/css/button.css.js +46 -0
  46. package/dist/css/dialog.css.d.ts +2 -0
  47. package/dist/css/dialog.css.js +11 -0
  48. package/dist/css/forms.css.d.ts +2 -0
  49. package/dist/css/forms.css.js +123 -0
  50. package/dist/css/modal.css.d.ts +2 -0
  51. package/dist/css/modal.css.js +15 -0
  52. package/dist/css/pb33f-theme.css +1 -0
  53. package/dist/css/radiogroups.css.d.ts +2 -0
  54. package/dist/css/radiogroups.css.js +26 -0
  55. package/dist/css/spinner.css.d.ts +2 -0
  56. package/dist/css/spinner.css.js +42 -0
  57. package/dist/events/doctor.d.ts +57 -3
  58. package/dist/events/doctor.js +13 -1
  59. package/dist/model/errors.d.ts +10 -0
  60. package/dist/model/rule_documentation.d.ts +8 -2
  61. package/dist/model/rule_documentation.js +5 -1
  62. package/dist/model/toast.d.ts +15 -0
  63. package/dist/model/toast.js +9 -0
  64. package/dist/model/vacuum_rule.d.ts +58 -0
  65. package/dist/model/vacuum_rule.js +1 -0
  66. package/dist/services/linting-service.d.ts +1 -1
  67. package/dist/services/linting-service.js +2 -6
  68. package/dist/services/ruleset-service.d.ts +17 -0
  69. package/dist/services/ruleset-service.js +316 -0
  70. package/dist/style.css +1 -1
  71. package/dist/workers/rule-documentation.worker.d.ts +7 -4
  72. package/dist/workers/rule-documentation.worker.js +93 -2
  73. package/package.json +1 -1
  74. package/dist/assets/rule-documentation.worker-BFIxMBU8.js +0 -1
@@ -0,0 +1,316 @@
1
+ export class RulesetService {
2
+ static checkRules(ruleset) {
3
+ ruleset.rules.forEach((rule, name) => {
4
+ if (rule.id !== name) {
5
+ rule.id = name;
6
+ }
7
+ });
8
+ }
9
+ static async getDefaultRuleset() {
10
+ return new Promise(async (resolve, reject) => {
11
+ try {
12
+ const defaultRuleset = await fetch(RulesetService.doctorEndpoint + '/rulesets/default', {
13
+ method: 'GET',
14
+ credentials: 'include',
15
+ headers: {
16
+ 'Content-Type': 'application/json'
17
+ },
18
+ });
19
+ const apiResult = await defaultRuleset.json();
20
+ if (!apiResult) {
21
+ reject({ detail: 'unable to fetch default ruleset' });
22
+ return;
23
+ }
24
+ if (apiResult?.type && apiResult?.title && apiResult?.status) {
25
+ reject(apiResult);
26
+ return;
27
+ }
28
+ resolve(apiResult);
29
+ }
30
+ catch (e) {
31
+ reject({ detail: 'unable fetch default ruleset: ' + e });
32
+ }
33
+ });
34
+ }
35
+ static async getOWASPRuleset() {
36
+ return new Promise(async (resolve, reject) => {
37
+ try {
38
+ const owaspRuleset = await fetch(RulesetService.doctorEndpoint + '/rulesets/owasp', {
39
+ method: 'GET',
40
+ credentials: 'include',
41
+ headers: {
42
+ 'Content-Type': 'application/json'
43
+ },
44
+ });
45
+ const apiResult = await owaspRuleset.json();
46
+ if (!apiResult) {
47
+ reject({ detail: 'unable to fetch owasp ruleset' });
48
+ return;
49
+ }
50
+ if (apiResult?.type && apiResult?.title && apiResult?.status) {
51
+ reject(apiResult);
52
+ return;
53
+ }
54
+ resolve(apiResult);
55
+ }
56
+ catch (e) {
57
+ reject({ detail: 'unable fetch owasp ruleset: ' + e });
58
+ }
59
+ });
60
+ }
61
+ static async getAllRuleset() {
62
+ return new Promise(async (resolve, reject) => {
63
+ try {
64
+ const allRuleset = await fetch(RulesetService.doctorEndpoint + '/rulesets/all', {
65
+ method: 'GET',
66
+ credentials: 'include',
67
+ headers: {
68
+ 'Content-Type': 'application/json'
69
+ },
70
+ });
71
+ const apiResult = await allRuleset.json();
72
+ if (!apiResult) {
73
+ reject({ detail: 'unable to fetch all rules ruleset' });
74
+ return;
75
+ }
76
+ if (apiResult?.type && apiResult?.title && apiResult?.status) {
77
+ reject(apiResult);
78
+ return;
79
+ }
80
+ resolve(apiResult);
81
+ }
82
+ catch (e) {
83
+ reject({ detail: 'unable fetch all rules ruleset: ' + e });
84
+ }
85
+ });
86
+ }
87
+ static async getFunctions() {
88
+ return new Promise(async (resolve, reject) => {
89
+ try {
90
+ const functions = await fetch(RulesetService.doctorEndpoint + '/rulesets/functions', {
91
+ method: 'GET',
92
+ credentials: 'include',
93
+ headers: {
94
+ 'Content-Type': 'application/json'
95
+ },
96
+ });
97
+ const apiResult = await functions.json();
98
+ if (!apiResult) {
99
+ reject({ details: 'unable to fetch functions' });
100
+ return;
101
+ }
102
+ if (apiResult?.type && apiResult?.title && apiResult?.status) {
103
+ reject(apiResult);
104
+ return;
105
+ }
106
+ resolve(apiResult);
107
+ }
108
+ catch (e) {
109
+ reject({ detail: 'unable fetch functions ' + e });
110
+ }
111
+ });
112
+ }
113
+ static async getFunctionSchema(functionId) {
114
+ return new Promise(async (resolve, reject) => {
115
+ try {
116
+ const functions = await fetch(RulesetService.doctorEndpoint + '/rulesets/functions/schemas/' + functionId, {
117
+ method: 'GET',
118
+ credentials: 'include',
119
+ headers: {
120
+ 'Content-Type': 'application/json'
121
+ },
122
+ });
123
+ const apiResult = await functions.json();
124
+ if (!apiResult) {
125
+ reject({ details: 'unable to fetch functions' });
126
+ return;
127
+ }
128
+ if (apiResult?.type && apiResult?.title && apiResult?.status) {
129
+ reject(apiResult);
130
+ return;
131
+ }
132
+ resolve(apiResult);
133
+ }
134
+ catch (e) {
135
+ reject({ detail: 'unable fetch function schema ' + e });
136
+ }
137
+ });
138
+ }
139
+ static async applyRuleset(ruleset) {
140
+ return new Promise(async (resolve, reject) => {
141
+ try {
142
+ const functions = await fetch(RulesetService.doctorEndpoint + '/rulesets/session', {
143
+ method: 'POST',
144
+ credentials: 'include',
145
+ headers: {
146
+ 'Content-Type': 'application/json'
147
+ },
148
+ body: ruleset
149
+ });
150
+ const apiResult = await functions.json();
151
+ if (!apiResult) {
152
+ reject({ detail: 'unable to apply ruleset' });
153
+ return;
154
+ }
155
+ if (apiResult?.type && apiResult?.title && apiResult?.status) {
156
+ reject(apiResult);
157
+ return;
158
+ }
159
+ resolve(apiResult);
160
+ }
161
+ catch (e) {
162
+ reject(e);
163
+ }
164
+ });
165
+ }
166
+ static async convertToJSON(ruleset) {
167
+ return new Promise(async (resolve, reject) => {
168
+ try {
169
+ const converted = await fetch(RulesetService.doctorEndpoint + '/rulesets/convert', {
170
+ method: 'POST',
171
+ credentials: 'include',
172
+ headers: {
173
+ 'Content-Type': 'application/json'
174
+ },
175
+ body: ruleset
176
+ });
177
+ const apiResult = await converted.json();
178
+ if (!apiResult) {
179
+ reject({ detail: 'unable to apply ruleset' });
180
+ return;
181
+ }
182
+ if (apiResult?.type && apiResult?.title && apiResult?.status) {
183
+ reject(apiResult);
184
+ return;
185
+ }
186
+ resolve(apiResult);
187
+ }
188
+ catch (e) {
189
+ reject(e);
190
+ }
191
+ });
192
+ }
193
+ static async getSessionRuleset() {
194
+ return new Promise(async (resolve, reject) => {
195
+ try {
196
+ const functions = await fetch(RulesetService.doctorEndpoint + '/rulesets/session', {
197
+ method: 'GET',
198
+ credentials: 'include',
199
+ headers: {
200
+ 'Content-Type': 'application/json'
201
+ },
202
+ });
203
+ const apiResult = await functions.json();
204
+ if (!apiResult) {
205
+ reject({ detail: 'unable to extract session ruleset' });
206
+ return;
207
+ }
208
+ if (apiResult?.type && apiResult?.title && apiResult?.status) {
209
+ reject(apiResult);
210
+ return;
211
+ }
212
+ resolve(apiResult);
213
+ }
214
+ catch (e) {
215
+ reject({ detail: 'unable to extract session ruleset' + e });
216
+ }
217
+ });
218
+ }
219
+ static async getSessionRulesetAsYAML() {
220
+ return new Promise(async (resolve, reject) => {
221
+ try {
222
+ const functions = await fetch(RulesetService.doctorEndpoint + '/rulesets/session/yaml', {
223
+ method: 'GET',
224
+ credentials: 'include',
225
+ headers: {
226
+ 'Content-Type': 'application/json'
227
+ },
228
+ });
229
+ const apiResult = await functions.text();
230
+ if (!apiResult) {
231
+ reject({ detail: 'unable to extract session ruleset' });
232
+ return;
233
+ }
234
+ resolve(apiResult);
235
+ }
236
+ catch (e) {
237
+ reject({ detail: 'unable to extract session ruleset' + e });
238
+ }
239
+ });
240
+ }
241
+ static async getSessionRulesetMap() {
242
+ return new Promise(async (resolve, reject) => {
243
+ try {
244
+ const map = await fetch(RulesetService.doctorEndpoint + '/rulesets/session/map', {
245
+ method: 'GET',
246
+ credentials: 'include',
247
+ headers: {
248
+ 'Content-Type': 'application/json'
249
+ },
250
+ });
251
+ const apiResult = await map.json();
252
+ if (!apiResult) {
253
+ reject({ detail: 'unable to extract session ruleset map' });
254
+ return;
255
+ }
256
+ resolve(apiResult);
257
+ }
258
+ catch (e) {
259
+ reject({ detail: 'unable to extract session ruleset' + e });
260
+ }
261
+ });
262
+ }
263
+ static async validateRuleset(body, returnJSON = true) {
264
+ return new Promise(async (resolve, reject) => {
265
+ try {
266
+ let jsonQuery = '';
267
+ if (returnJSON) {
268
+ jsonQuery = '?json=true';
269
+ }
270
+ const functions = await fetch(RulesetService.doctorEndpoint + '/rulesets/validate' + jsonQuery, {
271
+ method: 'POST',
272
+ credentials: 'include',
273
+ headers: {
274
+ 'Content-Type': 'application/json'
275
+ },
276
+ body: body
277
+ });
278
+ const apiResult = await functions.json();
279
+ if (!apiResult) {
280
+ reject({ detail: 'unable to validate ruleset' });
281
+ return;
282
+ }
283
+ if (apiResult?.type && apiResult?.title && apiResult?.status) {
284
+ reject(apiResult);
285
+ return;
286
+ }
287
+ resolve(apiResult);
288
+ }
289
+ catch (e) {
290
+ reject({ detail: 'unable to validate ruleset' + e });
291
+ }
292
+ });
293
+ }
294
+ static async resetSessionRuleset() {
295
+ return new Promise(async (resolve, reject) => {
296
+ try {
297
+ const functions = await fetch(RulesetService.doctorEndpoint + '/rulesets/session', {
298
+ method: 'DELETE',
299
+ credentials: 'include',
300
+ headers: {
301
+ 'Content-Type': 'application/json'
302
+ },
303
+ });
304
+ if (functions.status !== 200) {
305
+ reject({ detail: 'unable to reset session ruleset' });
306
+ return;
307
+ }
308
+ resolve(null);
309
+ }
310
+ catch (e) {
311
+ reject({ detail: 'unable to extract session ruleset' + e });
312
+ }
313
+ });
314
+ }
315
+ }
316
+ RulesetService.doctorEndpoint = 'https://doctor.pb33f.io';