Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ReDoS when parsing colors #3382

Merged
merged 1 commit into from Jul 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Fix ReDoS when parsing colors
  • Loading branch information
matias-la committed Jul 12, 2022
commit 7adf06d0c59382d884a04be86a96eede3d0432fa
2 changes: 1 addition & 1 deletion src/reanimated2/Colors.ts
Expand Up @@ -23,7 +23,7 @@
}

// var INTEGER = '[-+]?\\d+';
const NUMBER = '[-+]?\\d*\\.?\\d+';
const NUMBER = '[-+]?\\d*(?:\\.\\d*)?';
const PERCENTAGE = NUMBER + '%';

function call(...args: unknown[]): string {
Expand Down Expand Up @@ -154,7 +154,7 @@
return int / 100;
}

const names: any = !isConfigured()

Check warning on line 157 in src/reanimated2/Colors.ts

GitHub Actions / check

src/reanimated2/Colors.ts#L157

Unexpected any. Specify a different type
? null
: makeShareable({
transparent: 0x00000000,
Expand Down Expand Up @@ -475,7 +475,7 @@
*/
export function RGBtoHSV(rgb: RGB): HSV;
export function RGBtoHSV(r: number, g: number, b: number): HSV;
export function RGBtoHSV(r: any, g?: any, b?: any): HSV {

Check warning on line 478 in src/reanimated2/Colors.ts

GitHub Actions / check

src/reanimated2/Colors.ts#L478

Unexpected any. Specify a different type

Check warning on line 478 in src/reanimated2/Colors.ts

GitHub Actions / check

src/reanimated2/Colors.ts#L478

Unexpected any. Specify a different type

Check warning on line 478 in src/reanimated2/Colors.ts

GitHub Actions / check

src/reanimated2/Colors.ts#L478

Unexpected any. Specify a different type
'worklet';
/* eslint-disable */
if (arguments.length === 1) {
Expand Down Expand Up @@ -528,7 +528,7 @@
*/
function HSVtoRGB(hsv: HSV): RGB;
function HSVtoRGB(h: number, s: number, v: number): RGB;
function HSVtoRGB(h: any, s?: any, v?: any) {

Check warning on line 531 in src/reanimated2/Colors.ts

GitHub Actions / check

src/reanimated2/Colors.ts#L531

Unexpected any. Specify a different type

Check warning on line 531 in src/reanimated2/Colors.ts

GitHub Actions / check

src/reanimated2/Colors.ts#L531

Unexpected any. Specify a different type

Check warning on line 531 in src/reanimated2/Colors.ts

GitHub Actions / check

src/reanimated2/Colors.ts#L531

Unexpected any. Specify a different type
'worklet';
/* eslint-disable */
var r, g, b, i, f, p, q, t;
Expand Down Expand Up @@ -636,7 +636,7 @@

export function convertToHSVA(color: unknown): ParsedColorArray {
'worklet';
const processedColor = processColorInitially(color)!; // argb;

Check warning on line 639 in src/reanimated2/Colors.ts

GitHub Actions / check

src/reanimated2/Colors.ts#L639

Forbidden non-null assertion
const a = (processedColor >>> 24) / 255;
const r = (processedColor << 8) >>> 24;
const g = (processedColor << 16) >>> 24;
Expand Down