@contrail/cli 3.5.0-alpha.dd20a19 → 3.5.1-alpha.68d57e0

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 (72) hide show
  1. package/README.md +1 -33
  2. package/node_modules/@contrail/loader/lib/color-processor.js +9 -23
  3. package/node_modules/@contrail/loader/lib/color-processor.spec.js +112 -62
  4. package/node_modules/@contrail/loader/lib/common/chunk-by-url-length.d.ts +1 -1
  5. package/node_modules/@contrail/loader/lib/common/chunk-by-url-length.js +2 -0
  6. package/node_modules/@contrail/loader/lib/common/chunk-by-url-length.spec.js +4 -0
  7. package/node_modules/@contrail/loader/lib/common/color-validation.d.ts +26 -0
  8. package/node_modules/@contrail/loader/lib/common/color-validation.js +163 -0
  9. package/node_modules/@contrail/loader/lib/common/color-validation.spec.js +102 -0
  10. package/node_modules/@contrail/loader/lib/common/size-range-helpers.js +0 -1
  11. package/node_modules/@contrail/loader/lib/constants.d.ts +0 -3
  12. package/node_modules/@contrail/loader/lib/constants.js +1 -4
  13. package/node_modules/@contrail/loader/lib/entities-v2/colors-v2/color-processor-v2.js +9 -23
  14. package/node_modules/@contrail/loader/lib/entities-v2/colors-v2/color-processor-v2.spec.js +112 -62
  15. package/node_modules/@contrail/loader/lib/entities-v2/entities-helper.js +0 -1
  16. package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/assortment-processor.js +0 -1
  17. package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.js +8 -22
  18. package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.spec.js +43 -1
  19. package/node_modules/@contrail/loader/lib/pipeline/identifier-resolver.d.ts +5 -0
  20. package/node_modules/@contrail/loader/lib/pipeline/identifier-resolver.js +562 -0
  21. package/node_modules/@contrail/loader/lib/pipeline/identifier-resolver.spec.js +231 -0
  22. package/node_modules/@contrail/loader/lib/pipeline/item-execute-helpers.js +77 -3
  23. package/node_modules/@contrail/loader/lib/pipeline/item-execute-helpers.spec.js +82 -0
  24. package/node_modules/@contrail/loader/lib/pipeline/preview.js +0 -5
  25. package/node_modules/@contrail/loader/lib/pipeline/preview.spec.js +2 -2
  26. package/node_modules/@contrail/loader/lib/pipeline/project-item-execute-helpers.js +1 -1
  27. package/node_modules/@contrail/loader/lib/pipeline/transform.js +18 -0
  28. package/node_modules/@contrail/loader/lib/pipeline/transform.spec.js +3 -2
  29. package/node_modules/@contrail/loader/lib/pipeline/types.d.ts +5 -2
  30. package/node_modules/@contrail/loader/lib/pipeline/types.js +2 -0
  31. package/node_modules/@contrail/loader/lib/pipeline/validate.js +184 -437
  32. package/node_modules/@contrail/loader/lib/pipeline/validate.spec.js +157 -53
  33. package/node_modules/@contrail/loader/package.json +3 -2
  34. package/node_modules/@contrail/sdk/.github/workflows/publish-to-npm.yml +120 -0
  35. package/node_modules/@contrail/sdk/lib/auth/login.js +42 -3
  36. package/node_modules/@contrail/sdk/lib/core/request.d.ts +3 -0
  37. package/node_modules/@contrail/sdk/lib/core/request.js +100 -4
  38. package/node_modules/@contrail/sdk/lib/entities/entities.client.js +1 -1
  39. package/node_modules/@contrail/sdk/lib/entities/entity.resource.registry.js +1 -0
  40. package/node_modules/@contrail/sdk/lib/files/files.d.ts +13 -3
  41. package/node_modules/@contrail/sdk/lib/files/files.js +66 -25
  42. package/node_modules/@contrail/sdk/package.json +4 -1
  43. package/node_modules/validate-color/LICENSE +21 -0
  44. package/node_modules/validate-color/README.md +265 -0
  45. package/node_modules/validate-color/lib/index.d.ts +10 -0
  46. package/node_modules/validate-color/lib/index.js +1 -0
  47. package/node_modules/validate-color/package.json +91 -0
  48. package/node_modules/validate-color/test/redos.js +29 -0
  49. package/oclif.manifest.json +1 -79
  50. package/package.json +3 -6
  51. package/dist/api/dash0/client.d.ts +0 -13
  52. package/dist/api/dash0/client.js +0 -53
  53. package/dist/api/dash0/spans.d.ts +0 -8
  54. package/dist/api/dash0/spans.js +0 -91
  55. package/dist/api/dash0/types.d.ts +0 -84
  56. package/dist/api/dash0/types.js +0 -4
  57. package/dist/commands/event-workflows/assess-impact.d.ts +0 -19
  58. package/dist/commands/event-workflows/assess-impact.js +0 -104
  59. package/dist/helpers/event-workflow-impact/aggregate.d.ts +0 -23
  60. package/dist/helpers/event-workflow-impact/aggregate.js +0 -49
  61. package/dist/helpers/event-workflow-impact/aggregate.spec.js +0 -109
  62. package/dist/helpers/event-workflow-impact/classify.d.ts +0 -13
  63. package/dist/helpers/event-workflow-impact/classify.js +0 -135
  64. package/dist/helpers/event-workflow-impact/classify.spec.js +0 -138
  65. package/dist/helpers/event-workflow-impact/render.d.ts +0 -12
  66. package/dist/helpers/event-workflow-impact/render.js +0 -62
  67. package/dist/helpers/event-workflow-impact/subtree.d.ts +0 -20
  68. package/dist/helpers/event-workflow-impact/subtree.js +0 -93
  69. package/dist/helpers/event-workflow-impact/subtree.spec.d.ts +0 -1
  70. package/dist/helpers/event-workflow-impact/subtree.spec.js +0 -103
  71. /package/{dist/helpers/event-workflow-impact/aggregate.spec.d.ts → node_modules/@contrail/loader/lib/common/color-validation.spec.d.ts} +0 -0
  72. /package/{dist/helpers/event-workflow-impact/classify.spec.d.ts → node_modules/@contrail/loader/lib/pipeline/identifier-resolver.spec.d.ts} +0 -0
@@ -17,6 +17,13 @@ const node_fetch_1 = __importDefault(require("node-fetch"));
17
17
  const entities_1 = require("../entities");
18
18
  const FormData = require('form-data');
19
19
  const file_type_helper_1 = require("./file-type-helper");
20
+ const RETRYABLE_HTTP_STATUSES = new Set([408, 429, 500, 502, 503, 504]);
21
+ class NonRetryableError extends Error {
22
+ constructor(cause) {
23
+ super(cause.message);
24
+ this.cause = cause;
25
+ }
26
+ }
20
27
  class Files {
21
28
  constructor(ctx) {
22
29
  this.ctx = ctx;
@@ -69,36 +76,70 @@ class Files {
69
76
  }
70
77
  uploadFile(uploadPost, file) {
71
78
  return __awaiter(this, void 0, void 0, function* () {
72
- const formData = new FormData();
73
- formData.append('Content-Type', file.type || file_type_helper_1.FileTypeHelper.getContentType(file));
74
- this.appendUploadHeaders(uploadPost, formData);
75
- formData.append('file', file);
76
- yield (0, node_fetch_1.default)(uploadPost.url, { method: 'POST', body: formData });
79
+ return this.withRetry(() => __awaiter(this, void 0, void 0, function* () {
80
+ const formData = new FormData();
81
+ formData.append('Content-Type', file.type || file_type_helper_1.FileTypeHelper.getContentType(file));
82
+ this.appendUploadHeaders(uploadPost, formData);
83
+ formData.append('file', file);
84
+ const response = yield (0, node_fetch_1.default)(uploadPost.url, { method: 'POST', body: formData });
85
+ if (!response.ok) {
86
+ const errorText = yield response.text();
87
+ const error = new Error(`File upload failed with status ${response.status}: ${errorText}`);
88
+ if (!RETRYABLE_HTTP_STATUSES.has(response.status))
89
+ throw new NonRetryableError(error);
90
+ throw error;
91
+ }
92
+ yield response.text();
93
+ }), 'Files.uploadFile', () => console.error(`[Files.uploadFile: Max attempts reached] file: ${file.name}, size: ${file.size}`));
77
94
  });
78
95
  }
79
96
  uploadFileAsStream(uploadPost, buffer, options) {
80
97
  return __awaiter(this, void 0, void 0, function* () {
81
- const formData = new FormData();
82
- formData.append('Content-Type', options.contentType);
83
- this.appendUploadHeaders(uploadPost, formData);
84
- formData.append('file', buffer);
85
- return new Promise((res, rej) => {
86
- formData.getLength((err, len) => __awaiter(this, void 0, void 0, function* () {
87
- if (err) {
88
- rej(err);
98
+ return this.withRetry(() => __awaiter(this, void 0, void 0, function* () {
99
+ const formData = new FormData();
100
+ if (options === null || options === void 0 ? void 0 : options.contentType) {
101
+ formData.append('Content-Type', options.contentType);
102
+ }
103
+ this.appendUploadHeaders(uploadPost, formData);
104
+ formData.append('file', buffer);
105
+ const contentLength = yield new Promise((resolve, reject) => {
106
+ formData.getLength((err, length) => (err ? reject(new NonRetryableError(err)) : resolve(length)));
107
+ });
108
+ const response = yield (0, node_fetch_1.default)(uploadPost.url, {
109
+ method: 'POST',
110
+ body: formData,
111
+ headers: { 'Content-Length': contentLength },
112
+ });
113
+ if (!response.ok) {
114
+ const errorText = yield response.text();
115
+ const error = new Error(`File upload failed with status ${response.status}: ${errorText}`);
116
+ if (!RETRYABLE_HTTP_STATUSES.has(response.status))
117
+ throw new NonRetryableError(error);
118
+ throw error;
119
+ }
120
+ yield response.text();
121
+ }), 'Files.uploadFileAsStream', () => console.error(`[Files.uploadFileAsStream: Max attempts reached] size: ${'size' in buffer ? buffer.size : buffer.length}`));
122
+ });
123
+ }
124
+ withRetry(operation, context, onExhausted) {
125
+ return __awaiter(this, void 0, void 0, function* () {
126
+ const MAX_ATTEMPTS = 3;
127
+ const RETRY_DELAY_MS = 1000;
128
+ for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
129
+ try {
130
+ return yield operation();
131
+ }
132
+ catch (error) {
133
+ if (error instanceof NonRetryableError)
134
+ throw error.cause;
135
+ console.error(`[Attempt ${attempt}][${context}: Error]`, error);
136
+ if (attempt >= MAX_ATTEMPTS) {
137
+ onExhausted();
138
+ throw error;
89
139
  }
90
- const response = yield (0, node_fetch_1.default)(uploadPost.url, {
91
- method: 'POST',
92
- body: formData,
93
- headers: {
94
- 'Content-Length': len,
95
- },
96
- });
97
- const text = yield response.text();
98
- console.log('text: ', text);
99
- res('ok');
100
- }));
101
- });
140
+ yield new Promise((resolve) => setTimeout(resolve, attempt * RETRY_DELAY_MS));
141
+ }
142
+ }
102
143
  });
103
144
  }
104
145
  appendUploadHeaders(uploadPost, formData) {
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@contrail/sdk",
3
- "version": "1.5.5",
3
+ "version": "1.5.13",
4
4
  "description": "Client library for interfacing with contrail services.",
5
5
  "homepage": "https://archergreysorg.github.io/contrail-lib/",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
6
9
  "main": "lib/index.js",
7
10
  "types": "lib/index.d.ts",
8
11
  "scripts": {
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Wallace Sidhrée
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,265 @@
1
+ ![Validate Color](https://raw.githubusercontent.com/dreamyguy/validate-color/master/docs/validate-color-logo-github-full-width.png "Validate all possible HTML colors!")
2
+
3
+ # Validate Color
4
+
5
+ > ✅🌈🙌 Validate HTML colors by `name`, `special name`, `hex`, `rgb`, `rgba`, `hsl`, `hsla`, `hwb`, `lab` or `lch` values
6
+
7
+ [![Build Status](https://travis-ci.com/dreamyguy/validate-color.svg?branch=master)](https://travis-ci.org/dreamyguy/validate-color) [![Node Version](https://img.shields.io/badge/node-v12.4.0-brightgreen.svg)](https://github.com/nodejs/node/releases/tag/v12.4.0)
8
+ [![NPM Version](https://img.shields.io/badge/npm-v6.9.0-brightgreen.svg)](https://github.com/npm/cli/releases/tag/v6.9.0)
9
+ [![MIT Licence](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/dreamyguy/validate-color/blob/master/LICENSE)
10
+
11
+ **_HTML colors are remarkably easy to get wrong_**, because they allow for so many different values.
12
+
13
+ As I was writing [Console Log Plus](https://github.com/dreamyguy/console-log-plus), I thought it would be great to allow users to pass any _HTML color_ they wanted as one of the parameter to the function. But since _HTML colors_ have so many variations and therefore are complex strings, it didn't take me long to realize that I'd have to make quite a few checks to validate the value passed by the user. That need brought me here.
14
+
15
+ **Validate Color** let's one validate the color string against all current possible _HTML color_ values. Some examples:
16
+
17
+ - `hex` - `#bada55`
18
+ - `name` - `LightGoldenrodYellow`
19
+ - `special name` - `currentColor`
20
+ - `rgb` - `rgb(0 0 0)`
21
+ - `rgba` - `rgba(0, 0, 0, .45)`
22
+ - `hsl` - `hsl(4.71239rad, 60%, 70%)`
23
+ - `hsla` - `hsla(180deg 100% 50% / .8)`
24
+ - `hwb` - `hwb(180deg 0% 0% / 100%)`
25
+ - `lab` - `lab(2000.1337% -8.6911 -159.131231 / .987189732)`
26
+ - `lch` - `lch(54.292% 106.839 40.853)`
27
+
28
+ Both `rgba` and `hsla` are now officially merged into their `rgb` and `hsl` counterparts, so the `a` can be omitted. The `a` is considered legacy syntax, so it will still work.
29
+
30
+ # Demo ✅ 🌈 🙌
31
+
32
+ To demonstrate the power of _validate-color_, I decided it would be best to create a living github page, that would serve both as a way of showcase _validate-color_, and facilitate its use:
33
+
34
+ [https://dreamyguy.github.io/validate-color/][7]
35
+
36
+ On this page you can:
37
+
38
+ - **Validate HTML colors as you type**
39
+
40
+ _On my TODO list:_
41
+
42
+ - _See opaque colors against black and white backgrounds._
43
+ - _See colors with transparency in different contexts._
44
+
45
+ # Usage
46
+
47
+ **validate-color** is also [available as a package on `npm`][6] and can be installed as a depedency with:
48
+
49
+ npm i validate-color --save
50
+
51
+ As with any node module, first you'll have to import it with `require`:
52
+
53
+ ```javascript
54
+ var validateColor = require("validate-color").default;
55
+ ```
56
+
57
+ ...or through `import`:
58
+
59
+ ```javascript
60
+ import validateColor from "validate-color";
61
+ ```
62
+
63
+ Once you've done the import, you'll be able to do checks like (example in **React**):
64
+
65
+ ```javascript
66
+ import React from "react";
67
+ import validateColor from "validate-color";
68
+
69
+ const ColorBox = (props) => {
70
+ const { color = "", text = "" } = props;
71
+ const theColor = color && validateColor(color) ? color : "transparent";
72
+ return (
73
+ <div className="color-box" style={{ backgroundColor: theColor }}>
74
+ <p>{text}</p>
75
+ </div>
76
+ );
77
+ };
78
+
79
+ export default ColorBox;
80
+ ```
81
+
82
+ > 👉 The source for a full-fledged color validation component can be [viewed here](https://github.com/dreamyguy/validate-color/blob/master/src/app/App.js). That component can be [seen in action here][7].
83
+
84
+ # Extend
85
+
86
+ One can "extend" the library by using only parts of it.
87
+
88
+ **1. Validate only HTML colors (`hex`, `rgb`, `rgba`, `hsl`, `hsla`, `hwb`, `lab`, `lch`), without `name`**
89
+
90
+ ```javascript
91
+ import { validateHTMLColor } from "validate-color";
92
+ ```
93
+
94
+ **2. Validate only `HEX` colors**
95
+
96
+ ```javascript
97
+ import { validateHTMLColorHex } from "validate-color";
98
+ ```
99
+
100
+ **3. Validate only `HSL` colors**
101
+
102
+ ```javascript
103
+ import { validateHTMLColorHsl } from "validate-color";
104
+ ```
105
+
106
+ **4. Validate only `NAME` colors**
107
+
108
+ ```javascript
109
+ import { validateHTMLColorName } from "validate-color";
110
+ ```
111
+
112
+ **5. Validate only `RGB` colors**
113
+
114
+ ```javascript
115
+ import { validateHTMLColorRgb } from "validate-color";
116
+ ```
117
+
118
+ **6. Validate only `SPECIAL NAME` colors**
119
+
120
+ ```javascript
121
+ import { validateHTMLColorSpecialName } from "validate-color";
122
+ ```
123
+
124
+ **7. Validate only `HWB` colors**
125
+
126
+ ```javascript
127
+ import { validateHTMLColorHwb } from "validate-color";
128
+ ```
129
+
130
+ **8. Validate only `LAB` colors**
131
+
132
+ ```javascript
133
+ import { validateHTMLColorLab } from "validate-color";
134
+ ```
135
+
136
+ **9. Validate only `LCH` colors**
137
+
138
+ ```javascript
139
+ import { validateHTMLColorLch } from "validate-color";
140
+ ```
141
+
142
+ > 👉 I was proactive and added validation to these relatively new HTML/CSS colors (**HWB** & **LAB** & **LCH**), but since [they're still drafts at the time of this writing][9], they might still be not fully supported at the time of this reading.
143
+
144
+ # Preventing ReDoS (`regex` denial-of-service) attacks
145
+
146
+ A ReDoS vulnerability [was reported as an issue](https://github.com/dreamyguy/validate-color/issues/28) on Oct 14, 2022, but that went under my radar. It was just today (Jan 29, 2023) I came across the issue, and luckily I had time to look into it.
147
+
148
+ This vulnerability was officially reported as **`CVE-2021-40892`**, and is listed a few places: [1](https://nvd.nist.gov/vuln/detail/CVE-2021-40892), [2](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-40892), [3](https://security.snyk.io/vuln/SNYK-JS-VALIDATECOLOR-2935878), [4](https://cve.report/CVE-2021-40892), [5](https://feedly.com/cve/CVE-2021-40892).
149
+
150
+ A similar problem was reported for the [`color-string` package](https://security.snyk.io/vuln/SNYK-JS-COLORSTRING-1082939), versions < 1.5.5.
151
+
152
+ A good article by Godson Obielum: [How to protect against regex denial-of-service (ReDoS) attacks](https://blog.logrocket.com/protect-against-regex-denial-of-service-redos-attacks/).
153
+
154
+ The issue is caused by the "greedy" character in `regex`, the infamous `+`. I've made amendments that limit the number of both spaces and digits by `5`, instead of having no limits.
155
+
156
+ I've also made patterns stricter and removed redundant optionals, simplifying whenever possible.
157
+
158
+ > 👉 All current `regex` have been tested with https://regex.rip/ and `npx redos-detector check "<regex pattern>" --maxSteps 10000)` (see [redos-detector](https://www.npmjs.com/package/redos-detector) for more options).
159
+
160
+ **That will, from this point onwards, invalidate otherwise valid colors that cross that threshold.**
161
+
162
+ Since this is an important update, I'm releasing it as a patch ([`v2.2.3`](https://github.com/dreamyguy/validate-color/releases/tag/v2.2.3))
163
+
164
+ # Development
165
+
166
+ ## Getting started
167
+
168
+ Clone this repo locally. You'll need to have [NodeJS][1] installed. Install all dependencies by running:
169
+
170
+ npm i
171
+
172
+ ## Run it locally
173
+
174
+ To start the app locally, run:
175
+
176
+ npm run start
177
+
178
+ This command fires up the application on port `9900`, making it visible on http://localhost:9900. Because this app is based on [create-react-app][2], the port number should be configured on the [.env](https://github.com/dreamyguy/validate-color/blob/master/.env#L1) file.
179
+
180
+ ## Building the frontend for Production
181
+
182
+ When you're ready to build for production, run:
183
+
184
+ npm run build
185
+
186
+ This command compiles all production-optimised resources to a folder called **build**. It's meant to be run remotely, at the environment host, at build time.
187
+
188
+ ## Building for NPM
189
+
190
+ When you're done with your changes, run:
191
+
192
+ npm run build-npm
193
+
194
+ This command compiles the distribution-optimised `javascript` to `lib/index.js`, a file compiled out of [src/validate-color/index.js][3].
195
+
196
+ > 👉 Note that the `lib/` folder and its contents are only available at the [NPM distribution][6].
197
+
198
+ # Testing
199
+
200
+ This project wouldn't be complete without proper testing.
201
+
202
+ [Jest][4] is my Unit Testing framework of choice. It's well documented and shares good practices & syntax with its most known predecessors (Mocha, Jasmine, etc). [Babel][5] was introduced as a dependency to the project because of Jest, but it was worth it since now we can use **ES6** syntax on our tests as well.
203
+
204
+ Run all tests, in watch mode:
205
+
206
+ npm run test
207
+
208
+ Tests are also run through [Travis][8] on every push to `master`. The build status is shown [at the top of this README](https://github.com/dreamyguy/validate-color#validate-color).
209
+
210
+ > 👉 All tests are named according to the file they're testing: `index.js` -> _`index.test.js`_, and reside under the same directory. Since `Jest` comes as courtesy of [CRA][2], all tests should be placed under the [src/](https://github.com/dreamyguy/validate-color/blob/master/src/) folder.
211
+
212
+ # Deploying
213
+
214
+ This repo is a hybrid one. It:
215
+
216
+ - Builds the NPM distribution
217
+ - Builds the GitHub Page that serves as a demo/showcase
218
+
219
+ There are 3 commands one can run to deploy to these two places.
220
+
221
+ **Deploy to GitHub Pages**
222
+
223
+ npm run deploy
224
+
225
+ **Deploy to NPM**
226
+
227
+ npm run deploy-npm
228
+
229
+ **Deploy to both places at once**
230
+
231
+ npm run release
232
+
233
+ > ⚠️ Make sure to bump version before releasing!
234
+
235
+ ## Good to know
236
+
237
+ ### License
238
+
239
+ [MIT](LICENSE)
240
+
241
+ ### Credits & Resources
242
+
243
+ - [Source from which the color name list was extracted from](https://htmlcolorcodes.com/color-names/)
244
+ - [The Ultimate Guide to CSS Colors 2020 Edition](https://dev.to/alvaromontoro/the-ultimate-guide-to-css-colors-2020-edition-1bh1#hsl)
245
+ - [MDN: CSS Colors](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value)
246
+ - [MDN: Color Picker tool](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Colors/Color_picker_tool)
247
+ - [CSS Color Module Level 4 Editor's Draft][9]
248
+ - [Lea Verou: LCH colors in CSS: what, why, and how?][10]
249
+ - [LCH Colour Picker][11]
250
+
251
+ ### About
252
+
253
+ **Validate Color** was put together by [Wallace Sidhrée][1]. 👨‍💻🇳🇴
254
+
255
+ [1]: http://sidhree.com/
256
+ [2]: https://facebook.github.io/create-react-app/
257
+ [3]: https://github.com/dreamyguy/validate-color/blob/master/src/validate-color/index.js
258
+ [4]: https://jestjs.io/
259
+ [5]: https://babeljs.io/
260
+ [6]: https://www.npmjs.com/package/validate-color
261
+ [7]: https://dreamyguy.github.io/validate-color/
262
+ [8]: https://travis-ci.com/dreamyguy/validate-color
263
+ [9]: https://drafts.csswg.org/css-color/
264
+ [10]: https://lea.verou.me/2020/04/lch-colors-in-css-what-why-and-how/
265
+ [11]: https://css.land/lch/
@@ -0,0 +1,10 @@
1
+ export function validateHTMLColor(input: string): boolean;
2
+ export function validateHTMLColorHex(input: string): boolean;
3
+ export function validateHTMLColorHsl(input: string): boolean;
4
+ export function validateHTMLColorName(input: string): boolean;
5
+ export function validateHTMLColorRgb(input: string): boolean;
6
+ export function validateHTMLColorSpecialName(input: string): boolean;
7
+ export function validateHTMLColorHwb(input: string): boolean;
8
+ export function validateHTMLColorLab(input: string): boolean;
9
+ export function validateHTMLColorLch(input: string): boolean;
10
+ export default function validateColor(input: string): boolean;
@@ -0,0 +1 @@
1
+ module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var a=r[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,t),a.l=!0,a.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var a in e)t.d(n,a,function(r){return e[r]}.bind(null,a));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){"use strict";t.r(r),t.d(r,"validateHTMLColorName",(function(){return l})),t.d(r,"validateHTMLColorSpecialName",(function(){return i})),t.d(r,"validateHTMLColorHex",(function(){return u})),t.d(r,"validateHTMLColorRgb",(function(){return g})),t.d(r,"validateHTMLColorHsl",(function(){return y})),t.d(r,"validateHTMLColorHwb",(function(){return L})),t.d(r,"validateHTMLColorLab",(function(){return S})),t.d(r,"validateHTMLColorLch",(function(){return m})),t.d(r,"validateHTMLColor",(function(){return G}));const n=e=>e&&"string"==typeof e,a=["AliceBlue","AntiqueWhite","Aqua","Aquamarine","Azure","Beige","Bisque","Black","BlanchedAlmond","Blue","BlueViolet","Brown","BurlyWood","CadetBlue","Chartreuse","Chocolate","Coral","CornflowerBlue","Cornsilk","Crimson","Cyan","DarkBlue","DarkCyan","DarkGoldenrod","DarkGray","DarkGrey","DarkGreen","DarkKhaki","DarkMagenta","DarkOliveGreen","DarkOrange","DarkOrchid","DarkRed","DarkSalmon","DarkSeaGreen","DarkSlateBlue","DarkSlateGray","DarkSlateGrey","DarkTurquoise","DarkViolet","DeepPink","DeepSkyBlue","DimGray","DimGrey","DodgerBlue","FireBrick","FloralWhite","ForestGreen","Fuchsia","Gainsboro","GhostWhite","Gold","Goldenrod","Gray","Grey","Green","GreenYellow","HoneyDew","HotPink","IndianRed","Indigo","Ivory","Khaki","Lavender","LavenderBlush","LawnGreen","LemonChiffon","LightBlue","LightCoral","LightCyan","LightGoldenrodYellow","LightGray","LightGrey","LightGreen","LightPink","LightSalmon","LightSalmon","LightSeaGreen","LightSkyBlue","LightSlateGray","LightSlateGrey","LightSteelBlue","LightYellow","Lime","LimeGreen","Linen","Magenta","Maroon","MediumAquamarine","MediumBlue","MediumOrchid","MediumPurple","MediumSeaGreen","MediumSlateBlue","MediumSlateBlue","MediumSpringGreen","MediumTurquoise","MediumVioletRed","MidnightBlue","MintCream","MistyRose","Moccasin","NavajoWhite","Navy","OldLace","Olive","OliveDrab","Orange","OrangeRed","Orchid","PaleGoldenrod","PaleGreen","PaleTurquoise","PaleVioletRed","PapayaWhip","PeachPuff","Peru","Pink","Plum","PowderBlue","Purple","RebeccaPurple","Red","RosyBrown","RoyalBlue","SaddleBrown","Salmon","SandyBrown","SeaGreen","SeaShell","Sienna","Silver","SkyBlue","SlateBlue","SlateGray","SlateGrey","Snow","SpringGreen","SteelBlue","Tan","Teal","Thistle","Tomato","Turquoise","Violet","Wheat","White","WhiteSmoke","Yellow","YellowGreen"],o=["currentColor","inherit","transparent"],l=e=>{let r=!1;return n(e)&&a.map(t=>(e.toLowerCase()===t.toLowerCase()&&(r=!0),null)),r},i=e=>{let r=!1;return n(e)&&o.map(t=>(e.toLowerCase()===t.toLowerCase()&&(r=!0),null)),r},u=e=>{if(n(e)){const r=/^#([\da-f]{3}){1,2}$|^#([\da-f]{4}){1,2}$/i;return e&&r.test(e)}return!1},d="(([\\d]{0,5})((\\.([\\d]{1,5}))?))",s=`(${d}%)`,c="(([0-9]|[1-9][0-9]|100)%)",f=`(${c}|(0?((\\.([\\d]{1,5}))?))|1)`,h=`([\\s]{0,5})\\)?)(([\\s]{0,5})(\\/?)([\\s]{1,5})${`(((${c}))|(0?((\\.([\\d]{1,5}))?))|1))?`}([\\s]{0,5})\\)`,$="(-?(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-9][0-9]|3[0-5][0-9])((\\.([\\d]{1,5}))?)|360)(deg)?)",g=e=>{if(n(e)){const r="([\\s]{0,5})([\\d]{1,5})%?([\\s]{0,5}),?",t="((([\\s]{0,5}),?([\\s]{0,5}))|(([\\s]{1,5})))",n=new RegExp(`^(rgb)a?\\(${`${r}${t}`}${`${r}${t}`}${`${r}${t}`}(${"(\\/?([\\s]{0,5})(0?\\.?([\\d]{1,5})%?([\\s]{0,5}))?|1|0)"})?\\)$`);return e&&n.test(e)}return!1},y=e=>{if(n(e)){const r=new RegExp(`^(hsl)a?\\((([\\s]{0,5})(${$}|${"(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-9][0-9]|3[0-9][0-9]|400)grad)"}|${"((([0-5])?\\.([\\d]{1,5})|6\\.([0-9]|1[0-9]|2[0-8])|[0-6])rad)"}|${"((0?((\\.([\\d]{1,5}))?)|1)turn)"})((([\\s]{0,5}),([\\s]{0,5}))|(([\\s]{1,5}))))(([\\s]{0,5})(0|${c})((([\\s]{0,5}),([\\s]{0,5}))|(([\\s]{1,5}))))(([\\s]{0,5})(0|${c})([\\s]{0,5})\\)?)(([\\s]{0,5})(\\/?|,?)([\\s]{0,5})(((${c}))|(0?((\\.([\\d]{1,5}))?))|1))?\\)$`);return e&&r.test(e)}return!1},L=e=>{if(n(e)){const r=new RegExp(`^(hwb\\(([\\s]{0,5})${$}([\\s]{1,5}))((0|${c})([\\s]{1,5}))((0|${c})${h}$`);return e&&r.test(e)}return!1},S=e=>{if(n(e)){const r="(-?(([0-9]|[1-9][0-9]|1[0-5][0-9])((\\.([\\d]{1,5}))?)?|160))",t=new RegExp(`^(lab\\(([\\s]{0,5})${s}([\\s]{1,5})${r}([\\s]{1,5})${r}${h}$`);return e&&t.test(e)}return!1},m=e=>{if(n(e)){const r="((([0-9]|[1-9][0-9])?((\\.([\\d]{1,5}))?)|100)(%)?)",t=""+d,n=`((${$})|(0|${f})|(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-9][0-9]|3[0-5][0-9])((\\.([\\d]{1,5}))?)|360))`,a=`(\\/([\\s]{0,5})${f})`,o=new RegExp(`^lch\\(${`(([\\s]{0,5})${r}([\\s]{1,5})${t}([\\s]{1,5})${n}([\\s]{0,5})(${a})?)`}\\)$`);return e&&o.test(e)}return!1},G=e=>!!(e&&u(e)||g(e)||y(e)||L(e)||S(e)||m(e));r.default=e=>!!(e&&u(e)||l(e)||i(e)||g(e)||y(e)||L(e)||S(e)||m(e))}]);
@@ -0,0 +1,91 @@
1
+ {
2
+ "name": "validate-color",
3
+ "version": "2.2.4",
4
+ "private": false,
5
+ "description": "Validate HTML colors by 'name', 'special name', 'hex', 'rgb', 'rgba', 'hsl', 'hsla', 'hwb', 'lab' or 'lch' values",
6
+ "keywords": [
7
+ "validation",
8
+ "color",
9
+ "colors",
10
+ "colour",
11
+ "colours",
12
+ "validate color",
13
+ "validate colour",
14
+ "color validation",
15
+ "colour validation",
16
+ "HTML color validation",
17
+ "HTML colour validation",
18
+ "validate HTML color",
19
+ "validate HTML colour",
20
+ "hex",
21
+ "rgb",
22
+ "rgba",
23
+ "hsl",
24
+ "hsla",
25
+ "hwb",
26
+ "lab",
27
+ "lch",
28
+ "css"
29
+ ],
30
+ "homepage": "https://dreamyguy.github.io/validate-color/",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/dreamyguy/validate-color"
34
+ },
35
+ "main": "lib/index.js",
36
+ "types": "lib/index.d.ts",
37
+ "author": {
38
+ "name": "Wallace Sidhrée",
39
+ "email": "i@dreamyguy.com",
40
+ "url": "http://sidhree.com/"
41
+ },
42
+ "copyright": "Copyright (c) Wallace Sidhrée - All rights reserved.",
43
+ "license": "MIT",
44
+ "devDependencies": {
45
+ "@babel/core": "^7.15.8",
46
+ "@babel/preset-env": "^7.15.8",
47
+ "@babel/preset-react": "^7.14.5",
48
+ "babel-loader": "^8.2.3",
49
+ "fork-me-on-github": "^1.0.6",
50
+ "gh-pages": "^3.2.3",
51
+ "node-sass": "^6.0.1",
52
+ "react": "^17.0.2",
53
+ "react-dom": "^17.0.2",
54
+ "react-emojis": "^1.0.6",
55
+ "react-scripts": "^4.0.3",
56
+ "webpack": "4.44.2",
57
+ "webpack-cli": "^4.2.0"
58
+ },
59
+ "scripts": {
60
+ "start": "react-scripts start",
61
+ "prebuild": "echo 🚀 Runnin 'build', hang tight!",
62
+ "build": "react-scripts build",
63
+ "postbuild": "echo 🎉 'build' was completed",
64
+ "prebuild-npm": "./bin/preBuildNpm.sh",
65
+ "build-npm": "NODE_ENV=npm webpack --config webpack.config.npm.js",
66
+ "postbuild-npm": "./bin/postBuildNpm.sh",
67
+ "test": "react-scripts test",
68
+ "testTravis": "CI=true react-scripts test",
69
+ "eject": "react-scripts eject",
70
+ "predeploy": "npm run build",
71
+ "deploy": "gh-pages -d build",
72
+ "deploy-npm": "npm run build-npm && npm publish",
73
+ "release": "npm run deploy && npm run deploy-npm"
74
+ },
75
+ "eslintConfig": {
76
+ "extends": "react-app"
77
+ },
78
+ "browserslist": {
79
+ "production": [
80
+ ">0.2%",
81
+ "not dead",
82
+ "not op_mini all"
83
+ ],
84
+ "development": [
85
+ "last 1 chrome version",
86
+ "last 1 firefox version",
87
+ "last 1 safari version"
88
+ ]
89
+ },
90
+ "dependencies": {}
91
+ }
@@ -0,0 +1,29 @@
1
+ var validateColor = require('../lib/index');
2
+
3
+ function build_blank(n) {
4
+ // let ret = "rgb(0" // original
5
+ let ret = "rg"
6
+ for (let i = 0; i < n; i++) {
7
+ ret += " "
8
+ }
9
+ return ret + "!";
10
+ }
11
+
12
+ // 'rg !'
13
+ // 'rg !'
14
+
15
+ // * Simulating 'validateColor.validateHTMLColorRgb('rgb(0 0 0)')'
16
+
17
+ for(let i = 1; i <= 5000000; i++) {
18
+ const attackStr = build_blank(i)
19
+ if (i < 30) {
20
+ console.log('🚀 ~ file: redos.js:21 ~ attackStr', attackStr);
21
+ }
22
+ // if (i % 100 === 0) {
23
+ // const time = Date.now();
24
+ // const attackStr = build_blank(i)
25
+ // // validateColor.validateHTMLColorRgb(attackStr)
26
+ // const timeCost = Date.now() - time;
27
+ // console.log(`attackStr.length: ${attackStr.length}: ${timeCost} ms`)
28
+ // }
29
+ }
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.5.0-alpha.dd20a19",
2
+ "version": "3.5.1-alpha.68d57e0",
3
3
  "commands": {
4
4
  "app:create": {
5
5
  "id": "app:create",
@@ -672,84 +672,6 @@
672
672
  }
673
673
  }
674
674
  },
675
- "event-workflows:assess-impact": {
676
- "id": "event-workflows:assess-impact",
677
- "description": "Sample Dash0 traces of an event-workflow action and report per-invocation downstream impact.",
678
- "strict": true,
679
- "pluginName": "@contrail/cli",
680
- "pluginAlias": "@contrail/cli",
681
- "pluginType": "core",
682
- "aliases": [],
683
- "examples": [
684
- "contrail event-workflows assess-impact @gap-automations:bomCcCostUpdate",
685
- "contrail event-workflows assess-impact @gap-automations:bomCcCostUpdate --samples 25 --lookback 6h"
686
- ],
687
- "flags": {
688
- "logLevel": {
689
- "name": "logLevel",
690
- "type": "option",
691
- "char": "l",
692
- "description": "The Log Level",
693
- "required": false,
694
- "multiple": false,
695
- "options": [
696
- "error",
697
- "warn",
698
- "info",
699
- "debug"
700
- ]
701
- },
702
- "alwaysConfirmEnv": {
703
- "name": "alwaysConfirmEnv",
704
- "type": "option",
705
- "char": "e",
706
- "description": "The Environment variables",
707
- "required": false,
708
- "multiple": false,
709
- "options": [
710
- "true",
711
- "false"
712
- ],
713
- "default": "true"
714
- },
715
- "samples": {
716
- "name": "samples",
717
- "type": "option",
718
- "char": "s",
719
- "description": "Number of distinct traces to sample (10-100).",
720
- "multiple": false,
721
- "default": 50
722
- },
723
- "lookback": {
724
- "name": "lookback",
725
- "type": "option",
726
- "description": "How far back to search. Format: 30m | 6h | 2d.",
727
- "multiple": false,
728
- "default": "2d"
729
- },
730
- "dataset": {
731
- "name": "dataset",
732
- "type": "option",
733
- "description": "Dash0 dataset.",
734
- "multiple": false,
735
- "default": "prod"
736
- },
737
- "json": {
738
- "name": "json",
739
- "type": "boolean",
740
- "char": "j",
741
- "description": "JSON output (not yet implemented; flag reserved).",
742
- "allowNo": false
743
- }
744
- },
745
- "args": {
746
- "identifier": {
747
- "name": "identifier",
748
- "description": "Action identifier (contrail.event_workflow.action.identifier).",
749
- "required": true
750
- }
751
- }
752
- },
753
675
  "file:upload": {
754
676
  "id": "file:upload",
755
677
  "description": "Uploads a file to the VibeIQ platform",