-
Notifications
You must be signed in to change notification settings - Fork 793
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
Validate ransomware target directories #1288
Changes from 4 commits
0a1782a
73c61eb
8af93c4
3d48a11
1768c0c
54072b6
3496c71
dc305d8
df6082b
9d4ee88
d2dda45
638db3d
4bec957
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Defined in UI on ValidationFormats.js | ||
IP_RANGE = "ip-range" | ||
IP = "ip" | ||
VALID_DIR_LINUX = "valid-directory-linux" | ||
VALID_DIR_WINDOWS = "valid-directory-windows" | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,22 @@ | ||
const ipRegex = '((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)' | ||
const cidrNotationRegex = '([0-9]|1[0-9]|2[0-9]|3[0-2])' | ||
const hostnameRegex = '^([A-Za-z0-9]*[A-Za-z]+[A-Za-z0-9]*.?)*([A-Za-z0-9]*[A-Za-z]+[A-Za-z0-9]*)$' | ||
// path starts with `/` OR `$` | ||
const linuxDirRegex = '^/|\\$' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
// path starts like `C:\` OR `C:/` OR `$` OR `%abc%` | ||
VakarisZ marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const windowsDirRegex = '^([A-Za-z]:(\\\\|\\/))|\\$|(%\\w*\\d*\\s*%)' | ||
|
||
|
||
export const IP_RANGE = 'ip-range'; | ||
export const IP = 'ip'; | ||
export const VALID_DIR_LINUX = 'valid-directory-linux' | ||
export const VALID_DIR_WINDOWS = 'valid-directory-windows' | ||
|
||
export const formValidationFormats = { | ||
[IP_RANGE]: buildIpRangeRegex(), | ||
[IP]: buildIpRegex() | ||
[IP]: buildIpRegex(), | ||
[VALID_DIR_LINUX]: buildValidDirLinuxRegex(), | ||
[VALID_DIR_WINDOWS]: buildValidDirWindowsRegex() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't check if it's a valid directory. Doesn't even check if it's a directory, the regex would match a file as well. Maybe rename to |
||
}; | ||
|
||
function buildIpRangeRegex(){ | ||
|
@@ -22,3 +31,11 @@ function buildIpRangeRegex(){ | |
function buildIpRegex(){ | ||
return new RegExp('^'+ipRegex+'$') | ||
} | ||
|
||
function buildValidDirLinuxRegex() { | ||
return new RegExp(linuxDirRegex) | ||
} | ||
|
||
function buildValidDirWindowsRegex() { | ||
return new RegExp(windowsDirRegex) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the other comment, the name is misleading as this validator doesn't check if the directory is valid, it only checks if the start of the path looks like the start of an absolute path.