@pb33f/cowboy-components 0.1.15 → 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 (79) 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.d.ts +1 -1
  30. package/dist/components/problem-list/problem-list.js +1 -2
  31. package/dist/components/problems-overview/document-statistic.css.js +0 -1
  32. package/dist/components/problems-overview/problem-overview-group.css.js +1 -3
  33. package/dist/components/problems-overview/problem-overview-group.js +2 -2
  34. package/dist/components/problems-overview/problem-statistics.css.js +0 -5
  35. package/dist/components/problems-overview/problems-overview.css.js +0 -4
  36. package/dist/components/the-doctor/feedback.js +3 -3
  37. package/dist/components/the-doctor/status-bar.js +1 -1
  38. package/dist/components/the-doctor/the-doctor.css.js +99 -27
  39. package/dist/components/the-doctor/the-doctor.d.ts +65 -8
  40. package/dist/components/the-doctor/the-doctor.js +663 -63
  41. package/dist/components/toast/toast-component.css.d.ts +2 -0
  42. package/dist/components/toast/toast-component.css.js +151 -0
  43. package/dist/components/toast/toast-component.d.ts +19 -0
  44. package/dist/components/toast/toast-component.js +116 -0
  45. package/dist/components/toast/toast-manager.d.ts +13 -0
  46. package/dist/components/toast/toast-manager.js +54 -0
  47. package/dist/cowboy-components.umd.cjs +1375 -372
  48. package/dist/css/button.css.js +46 -0
  49. package/dist/css/dialog.css.d.ts +2 -0
  50. package/dist/css/dialog.css.js +11 -0
  51. package/dist/css/forms.css.d.ts +2 -0
  52. package/dist/css/forms.css.js +123 -0
  53. package/dist/css/modal.css.d.ts +2 -0
  54. package/dist/css/modal.css.js +15 -0
  55. package/dist/css/pb33f-theme.css +1 -0
  56. package/dist/css/radiogroups.css.d.ts +2 -0
  57. package/dist/css/radiogroups.css.js +26 -0
  58. package/dist/css/spinner.css.d.ts +2 -0
  59. package/dist/css/spinner.css.js +42 -0
  60. package/dist/events/doctor.d.ts +57 -3
  61. package/dist/events/doctor.js +13 -1
  62. package/dist/model/errors.d.ts +10 -0
  63. package/dist/model/rule_documentation.d.ts +8 -2
  64. package/dist/model/rule_documentation.js +5 -1
  65. package/dist/model/toast.d.ts +15 -0
  66. package/dist/model/toast.js +9 -0
  67. package/dist/model/vacuum_rule.d.ts +58 -0
  68. package/dist/model/vacuum_rule.js +1 -0
  69. package/dist/services/linting-service.d.ts +1 -1
  70. package/dist/services/linting-service.js +2 -6
  71. package/dist/services/ruleset-service.d.ts +17 -0
  72. package/dist/services/ruleset-service.js +316 -0
  73. package/dist/style.css +1 -1
  74. package/dist/workers/rule-documentation.worker.d.ts +9 -1
  75. package/dist/workers/rule-documentation.worker.js +97 -7
  76. package/dist/workers/search-problems.worker.d.ts +2 -1
  77. package/dist/workers/search-problems.worker.js +1 -2
  78. package/package.json +1 -1
  79. package/dist/assets/rule-documentation.worker-BFIxMBU8.js +0 -1
@@ -0,0 +1 @@
1
+ (function(){"use strict";var i=(t=>(t.RULE="rule",t.FUNCTION="function",t))(i||{});onmessage=function(t){if(t.data.start){const o=[u(t.data.endpoint),d(t.data.endpoint)];Promise.all(o).then(n=>{postMessage(n.flat())}).catch(()=>{console.error("documentation cannot be fetched")})}};async function u(t){return new Promise(async(o,n)=>{try{const r=(await m(t)).map(c=>f(c.ruleId,t).then(a=>(a.body&&(c.body=a.body),c.type=i.RULE,c))),s=await Promise.all(r);o(s)}catch(e){console.error("documentation service is down"),n(e)}})}async function d(t){return new Promise(async(o,n)=>{try{const r=(await y(t)).map(c=>h(c.functionId,t).then(a=>(a.body&&(c.body=a.body),c.type=i.FUNCTION,c))),s=await Promise.all(r);o(s)}catch(e){console.error("documentation service is down"),n(e)}})}async function m(t){try{const n=await(await fetch(t+"/rules/documentation",{method:"GET",credentials:"include",headers:{"Content-Type":"application/json"}})).json();return n?n!=null&&n.error?new Promise(async(e,r)=>{r(n.error)}):n:new Promise(async(e,r)=>{r("nothing returned")})}catch(o){return new Promise(async(n,e)=>{e(o)})}}async function y(t){try{const n=await(await fetch(t+"/functions/documentation",{method:"GET",credentials:"include",headers:{"Content-Type":"application/json"}})).json();return n?n!=null&&n.error?new Promise(async(e,r)=>{r(n.error)}):n:new Promise(async(e,r)=>{r("nothing returned")})}catch(o){return new Promise(async(n,e)=>{e(o)})}}async function f(t,o){try{const e=await(await fetch(o+`/rules/documentation/${t}`,{method:"GET",credentials:"include",headers:{"Content-Type":"application/json"}})).json();return e?e!=null&&e.error?new Promise(async(r,s)=>{s(e.error)}):e:new Promise(async(r,s)=>{s("nothing returned")})}catch(n){return new Promise(async(e,r)=>{r(n)})}}async function h(t,o){try{const e=await(await fetch(o+`/functions/documentation/${t}`,{method:"GET",credentials:"include",headers:{"Content-Type":"application/json"}})).json();return e?e!=null&&e.error?new Promise(async(r,s)=>{s(e.error)}):e:new Promise(async(r,s)=>{s("nothing returned")})}catch(n){return new Promise(async(e,r)=>{r(n)})}}})();
@@ -8,7 +8,9 @@ export declare class SpecEditor extends LitElement {
8
8
  theme?: string;
9
9
  language?: string;
10
10
  code?: string;
11
+ id: string;
11
12
  static styles: import("lit").CSSResult;
13
+ constructor(id?: string);
12
14
  private firstboot;
13
15
  render(): import("lit-html").TemplateResult<1>;
14
16
  private getFile;
@@ -36,9 +36,10 @@ self.MonacoEnvironment = {
36
36
  },
37
37
  };
38
38
  let SpecEditor = class SpecEditor extends LitElement {
39
- constructor() {
40
- super(...arguments);
39
+ constructor(id = "spec") {
40
+ super();
41
41
  this.container = createRef();
42
+ this.id = id;
42
43
  }
43
44
  render() {
44
45
  return html `
@@ -116,7 +117,7 @@ let SpecEditor = class SpecEditor extends LitElement {
116
117
  // @ts-ignore
117
118
  monaco.editor.defineTheme("pb33f", options);
118
119
  monaco.editor.setTheme('pb33f');
119
- const uri = monaco.Uri.parse("inmemory://doc");
120
+ const uri = monaco.Uri.parse("inmemory://doc-" + this.id);
120
121
  const value = this.getCode();
121
122
  this.model = monaco.editor.createModel(value, "yaml", uri);
122
123
  this.editor = monaco.editor.create(this.container.value, {
@@ -140,7 +141,8 @@ let SpecEditor = class SpecEditor extends LitElement {
140
141
  bubbles: true,
141
142
  composed: true,
142
143
  detail: {
143
- content: this.editor.getValue()
144
+ content: this.editor.getValue(),
145
+ id: this.id
144
146
  }
145
147
  }));
146
148
  }
@@ -7,7 +7,7 @@ export default css `
7
7
  position: absolute;
8
8
  top: 0;
9
9
  left: 0;
10
- z-index: 1000;
10
+ z-index: 100;
11
11
  width: 100%;
12
12
  overflow: hidden;
13
13
  }
@@ -0,0 +1,2 @@
1
+ declare const _default: import("lit").CSSResult;
2
+ export default _default;
@@ -0,0 +1,38 @@
1
+ import { css } from "lit";
2
+ export default css `
3
+
4
+ .option {
5
+ display: flex;
6
+ flex-flow: row wrap;
7
+ justify-content: flex-start;
8
+ align-items: center;
9
+ padding-bottom: 20px;
10
+ border-bottom: 1px dashed var(--secondary-color-dimmer);
11
+ }
12
+ sl-input {
13
+ margin-right: 20px;
14
+ }
15
+
16
+ sl-icon-button {
17
+ margin-top: 25px;
18
+ font-size: 1.2rem;
19
+ }
20
+
21
+ sl-textarea {
22
+ width: 100%;
23
+ }
24
+
25
+ sl-input::part(form-control-label) {
26
+ margin-top: 10px;
27
+ }
28
+
29
+ sl-textarea::part(form-control-label) {
30
+ margin-top: 10px;
31
+ }
32
+
33
+ p.description {
34
+ flex-basis:100%;
35
+ font-size: 0.8rem;
36
+ color: var(--font-color-sub2);
37
+ }
38
+ `;
@@ -0,0 +1,19 @@
1
+ import { LitElement } from "lit";
2
+ import { RuleComponent } from "./rule.js";
3
+ import { RuleAction } from "../../model/vacuum_rule.js";
4
+ import { SlInput, SlTextarea } from "@shoelace-style/shoelace";
5
+ export declare class FunctionOption extends LitElement {
6
+ static styles: import("lit").CSSResult[];
7
+ key: string;
8
+ value: string;
9
+ keyInput: SlInput;
10
+ keyValue: SlInput | SlTextarea;
11
+ private readonly rule;
12
+ private readonly action;
13
+ removeable: boolean;
14
+ private readonly description;
15
+ constructor(key: string, value: string, desc: string, rule: RuleComponent, action: RuleAction, removeable?: boolean);
16
+ removeSelf(): void;
17
+ dirty(): void;
18
+ render(): import("lit-html").TemplateResult<1>;
19
+ }
@@ -0,0 +1,117 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { customElement, property, query } from "lit/decorators.js";
8
+ import { html, LitElement } from "lit";
9
+ import formsCss from "../../css/forms.css.js";
10
+ import functionOptionCss from "./function-option.css.js";
11
+ import { RemoveFunctionOption, RulesetDirty } from "../../events/doctor.js";
12
+ let FunctionOption = class FunctionOption extends LitElement {
13
+ constructor(key, value, desc, rule, action, removeable = true) {
14
+ super();
15
+ this.key = key;
16
+ this.rule = rule;
17
+ this.value = value;
18
+ this.action = action;
19
+ this.removeable = removeable;
20
+ this.description = desc;
21
+ }
22
+ removeSelf() {
23
+ if (this.action.functionOptions && this.action.functionOptions instanceof Map) {
24
+ this.action.functionOptions.delete(this.key);
25
+ }
26
+ else {
27
+ if (this.action.functionOptions) {
28
+ delete this.action.functionOptions[this.key];
29
+ }
30
+ }
31
+ this.dirty();
32
+ this.dispatchEvent(new CustomEvent(RemoveFunctionOption, {
33
+ bubbles: true,
34
+ composed: true,
35
+ detail: {
36
+ action: this.action,
37
+ key: this.keyInput.value,
38
+ value: this.keyValue.value
39
+ }
40
+ }));
41
+ this.remove();
42
+ }
43
+ dirty() {
44
+ if (this.keyInput) {
45
+ this.key = this.keyInput.value;
46
+ }
47
+ if (this.keyValue) {
48
+ this.value = this.keyValue.value;
49
+ }
50
+ if (this.action.functionOptions && this.action.functionOptions instanceof Map) {
51
+ this.action.functionOptions.set(this.key, this.value);
52
+ }
53
+ else {
54
+ if (!this.action.functionOptions) {
55
+ this.action.functionOptions = {};
56
+ }
57
+ this.action.functionOptions = new Map(Object.entries(this.action.functionOptions));
58
+ this.action.functionOptions.set(this.key, this.value);
59
+ }
60
+ this.dispatchEvent(new CustomEvent(RulesetDirty, {
61
+ bubbles: true,
62
+ composed: true,
63
+ detail: {
64
+ rule: this.rule
65
+ }
66
+ }));
67
+ }
68
+ render() {
69
+ let valueInput = html `<sl-input id="value" size="small" label="Value" placeholder="Value" value="${this.value}"
70
+ @keydown="${this.dirty}" @sl-change="${this.dirty}"></sl-input>`;
71
+ if (typeof this.value == 'object' || this.key === 'schema') {
72
+ let v;
73
+ if (typeof this.value == 'object') {
74
+ v = JSON.stringify(this.value, null, 2);
75
+ }
76
+ else {
77
+ v = this.value;
78
+ }
79
+ if (v === '""' || v === '') {
80
+ v = '{}';
81
+ }
82
+ valueInput = html `<sl-textarea @keydown="${this.dirty}" id="value" resize="auto" size="small" label="Value" placeholder="Value" value=${v} @sl-change="${this.dirty}"></sl-textarea>`;
83
+ }
84
+ let removeButton = html `<sl-icon-button name="trash3" label="Remove" @click="${this.removeSelf}"></sl-icon-button>`;
85
+ if (!this.removeable) {
86
+ removeButton = html ``;
87
+ }
88
+ return html `
89
+ <section class="option">
90
+ <sl-input size="small" label="Key" id="key" placeholder="Key" value="${this.key}" @sl-change="${this.dirty}"></sl-input>
91
+ ${valueInput}
92
+ ${removeButton}
93
+ ${this.description.length > 0 ? html `<p class="description">${this.description}</p>` : html ``}
94
+ </section>
95
+ `;
96
+ }
97
+ };
98
+ FunctionOption.styles = [functionOptionCss, formsCss];
99
+ __decorate([
100
+ property()
101
+ ], FunctionOption.prototype, "key", void 0);
102
+ __decorate([
103
+ property()
104
+ ], FunctionOption.prototype, "value", void 0);
105
+ __decorate([
106
+ query('#key')
107
+ ], FunctionOption.prototype, "keyInput", void 0);
108
+ __decorate([
109
+ query('#value')
110
+ ], FunctionOption.prototype, "keyValue", void 0);
111
+ __decorate([
112
+ property({ type: Boolean })
113
+ ], FunctionOption.prototype, "removeable", void 0);
114
+ FunctionOption = __decorate([
115
+ customElement('pb33f-function-option')
116
+ ], FunctionOption);
117
+ export { FunctionOption };
@@ -0,0 +1,2 @@
1
+ declare const _default: import("lit").CSSResult;
2
+ export default _default;
@@ -0,0 +1,75 @@
1
+ import { css } from "lit";
2
+ export default css `
3
+ .ruleset {
4
+ font-size: 0.9rem;
5
+ margin-left: 5px;
6
+ margin-right: 3px;
7
+ }
8
+
9
+ .ruleset-header {
10
+ display: flex;
11
+ padding-bottom: 10px;
12
+ border-bottom: 1px dashed var(--secondary-color);
13
+ }
14
+
15
+ .ruleset-controls {
16
+ flex-grow: 2;
17
+ text-align: right;
18
+ padding-top: 2px;
19
+ }
20
+
21
+ sl-icon {
22
+ font-size: 1.2rem;
23
+ }
24
+
25
+ sl-icon-button {
26
+ font-size: 1.2rem;
27
+ color: var(--primary-color);
28
+ margin-top: 22px;
29
+ }
30
+
31
+ sl-icon-button#save-button {
32
+ color: var(--warn-color);
33
+ animation: pulse-animation 1.5s infinite;
34
+ }
35
+
36
+ @keyframes pulse-animation {
37
+ 0% {
38
+ box-shadow: 0 0 0 0 var(--warn-color);
39
+ }
40
+ 100% {
41
+ box-shadow: 0 0 0 5px rgb(0, 0, 0, 0);
42
+ }
43
+ }
44
+
45
+ .ruleset-body {
46
+ height: calc(100vh - 210px);
47
+ overflow-y: auto;
48
+ padding-right: 10px;
49
+ }
50
+
51
+ .ruleset-body::-webkit-scrollbar {
52
+ width: 8px;
53
+ }
54
+
55
+ .ruleset-body::-webkit-scrollbar-track {
56
+ background-color: black;
57
+ }
58
+
59
+ .ruleset-body::-webkit-scrollbar-thumb {
60
+ box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
61
+ background: var(--secondary-color-lowalpha);
62
+ padding: var(--global-padding);
63
+ }
64
+
65
+ .hidden {
66
+ display: none;
67
+ }
68
+
69
+ .toggle-allcheck {
70
+ padding-top: 5px;
71
+ padding-left: 2px;
72
+ }
73
+
74
+
75
+ `;
@@ -0,0 +1,62 @@
1
+ import '@shoelace-style/shoelace/dist/components/radio-group/radio-group.js';
2
+ import '@shoelace-style/shoelace/dist/components/radio-button/radio-button.js';
3
+ import '@shoelace-style/shoelace/dist/components/dialog/dialog.js';
4
+ import { LitElement } from "lit";
5
+ import { RuleComponent } from "./rule.js";
6
+ import { Rule, RuleConfig, RuleSet } from "../../model/vacuum_rule.js";
7
+ import { SlButton, SlDialog, SlRadioButton, SlRadioGroup, SlSwitch } from "@shoelace-style/shoelace";
8
+ import { RuleError } from "../../model/errors.js";
9
+ export declare class ManageRuleset extends LitElement {
10
+ static styles: import("lit").CSSResult[];
11
+ saveButton: SlButton;
12
+ exportButton: SlButton;
13
+ rulesetSelector: SlRadioGroup;
14
+ customRulesetSelector: SlRadioButton;
15
+ customWipeDialog: SlDialog;
16
+ confirmWipeButton: SlButton;
17
+ allRulesSwitch: SlSwitch;
18
+ private _defaultRuleset;
19
+ private _owaspRuleset;
20
+ private _allRuleset;
21
+ private _customRuleset;
22
+ private _rulesetConfig;
23
+ private _defaultRules;
24
+ private _owaspRules;
25
+ private _allRules;
26
+ private _customRules;
27
+ private _activeRuleset;
28
+ private _functions;
29
+ private dirtyRules;
30
+ private allRulesEnabled;
31
+ private currentRuleset;
32
+ private confirmWipeActive;
33
+ private confirmNewRuleset;
34
+ constructor();
35
+ private rulesetUpdated;
36
+ private exportRuleset;
37
+ private compileRuleset;
38
+ clearRuleProblems(): void;
39
+ processBadRules(ruleError: RuleError[]): void;
40
+ rulesetSaved(ruleset: RuleSet, returnedRuleset: RuleSet): void;
41
+ private dirty;
42
+ private copyActiveRulesetCustom;
43
+ private buildConfig;
44
+ private toggleAllRules;
45
+ set defaultRuleset(rs: RuleSet);
46
+ set owaspRuleset(rs: RuleSet);
47
+ set allRuleset(rs: RuleSet);
48
+ set customRuleset(rs: RuleSet);
49
+ set customRulesetManual(rs: RuleSet);
50
+ set rulesetConfig(config: RuleConfig);
51
+ set functions(funcs: string[]);
52
+ buildCustomRuleset(dirty?: boolean): void;
53
+ changeActiveRuleset(event: CustomEvent): void;
54
+ private cancelCustomOverride;
55
+ private confirmCustomOverride;
56
+ private switchRuleset;
57
+ buildRulesets(): void;
58
+ enableOrDisableRules(): void;
59
+ buildRule(ruleId: string, rule: Rule, rules: RuleComponent[], custom?: boolean): RuleComponent;
60
+ addCustomRule(): void;
61
+ render(): import("lit-html").TemplateResult<1>;
62
+ }