regex-vault
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "regex-vault", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "regex-vault is a centralized library of regular expressions for validation, security, and efficient data manipulation.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
// Regex para validar comandos de Firewall no linux (UFW) | ||
export const linuxFirewallUFWRegex = /^ufw\s+(enable|disable|status|logging\s+(on|off)|default\s+(allow|deny)\s+(incoming|outgoing)|allow\s+\d+(\/(tcp|udp))?|deny\s+\d+(\/(tcp|udp))?|delete\s+\S+(\s+(tcp|udp))?|allow\s+from\s+\d{1,3}(\.\d{1,3}){3}(\/\d+)?\s+to\s+any\s+port\s+\d+|deny\s+from\s+\d{1,3}(\.\d{1,3}){3}(\/\d+)?\s+to\s+any\s+port\s+\d+)$/; | ||
export const linuxFirewallUFWRegex = /^(sudo\s+)?ufw\s+(allow|deny|enable|disable|reload|reset|status(?:\s+numbered)?|logging\s+(on|off)|default\s+(allow|deny)\s+(incoming|outgoing)|allow\s+(\d+|ssh|http|https|ftp|smtp|dns|pop3|imap|smb|nfs|mysql|postgresql|mongodb)(\/(tcp|udp))?|deny\s+(\d+|ssh|http|https|ftp|smtp|dns|pop3|imap|smb|nfs|mysql|postgresql|mongodb)(\/(tcp|udp))?|delete\s+(allow|deny)?\s*(\d+|ssh|http|https|ftp|smtp|dns|pop3|imap|smb|nfs|mysql|postgresql|mongodb)?(\/(tcp|udp))?|allow\s+from\s+\d{1,3}(\.\d{1,3}){3}(\/\d+)?\s+to\s+any\s+port\s+\d+|deny\s+from\s+\d{1,3}(\.\d{1,3}){3}(\/\d+)?\s+to\s+any\s+port\s+\d+)$/; | ||
// Regex para validar comandos de Firewall no linux (iptables) | ||
export const linuxFirewallIptablesRegex = /^iptables\s+(-[AID]|--(?:append|delete|insert))\s+(INPUT|OUTPUT|FORWARD)(\s+-p\s+(?:tcp|udp))?(\s+--dport\s+\d+)?(\s+-j\s+(?:ACCEPT|DROP|REJECT))$/; | ||
export const linuxFirewallIptablesRegex = /^(sudo\s+)?(iptables(-save)?|\s*sh\s+-c\s+"iptables-save\s*>\s*\/[^\n"]+")(\s+(-[AIDFNRXZL]|--(?:append|delete|insert|flush|list|new|rename|zero|save|restore))(\s+(INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING))?(?:\s+-[a-zA-Z0-9-]+(?:\s+\S+)*)*)?$/; | ||
// Regex para validar comandos de Bluetooth no linux | ||
export const linuxBluetoothRegex = /^sudo\s+(?:systemctl\s+(?:start|stop|enable|disable|status)\s+bluetooth|bluetoothctl\s+(?:power\s+(?:on|off)|(?:pair|connect|disconnect|remove)\s+\S+))$/; | ||
export const linuxBluetoothRegex = /^(sudo\s+)?(systemctl\s+(start|stop|enable|disable|status)\s+bluetooth|bluetoothctl\s+(power\s+(on|off)|pair\s+\S+|connect\s+\S+|disconnect\s+\S+|remove\s+\S+)|rfkill\s+(block|unblock)\s+bluetooth)$/; | ||
// Regex para validar comandos de gerenciamento de USB no linux | ||
export const linuxUSBRegexManage = /^sudo\s+modprobe\s+(?:-r\s+)?usb_storage$/; | ||
//export const linuxUSBRegexManage = /^sudo\s+modprobe\s+(?:-r\s+)?usb_storage$/; | ||
export const linuxUSBRegexManage = /^sudo\s+(?:modprobe(?:\s+-r)?\s+usb_storage|tee\s+\/sys\/bus\/usb\/drivers\/usb\/(?:un)?bind)$/; | ||
// Regex para validar comandos de listagem de USB no linux | ||
export const linuxUSBRegexList = /^(?:lsusb|dmesg\s+\|\s+grep\s+"usb"|echo\s+'[0-9-]+'\s+\|\s+sudo\s+tee\s+\/sys\/bus\/usb\/drivers\/usb\/(?:un)?bind)$/; | ||
export const linuxUSBRegexList = /^(lsusb|dmesg\s+\|\s+grep\s+"usb"|echo\s+"[^"]+"\s+\|\s+sudo\s+tee\s+\/sys\/bus\/usb\/drivers\/usb\/(?:un)?bind)$/; | ||
// Regex para validar regras udev de bloqueio de dispositivos USB no linux | ||
@@ -12,0 +13,0 @@ export const linuxUSBRegexBlock = /^SUBSYSTEM=="usb",\s+ACTION=="add",\s+ATTR{idVendor}=="[0-9a-fA-F]{4}",\s+ATTR{idProduct}=="[0-9a-fA-F]{4}",\s+RUN\+="\/bin\/sh\s+-c\s+'exit\s+1'"$/; |
// Regex para validar comandos de Firewall no macOS | ||
export const macOSFirewallRegex = /^sudo\s+\/usr\/libexec\/ApplicationFirewall\/socketfilterfw\s+--(?:setglobalstate\s+(?:on|off)|setstealthmode\s+(?:on|off)|listapps|add\s+"[^"]+"|remove\s+"[^"]+")$/; | ||
export const macOSFirewallRegex = /^sudo\s+\/usr\/libexec\/ApplicationFirewall\/socketfilterfw\s+--(?:setglobalstate\s+(?:on|off)|setstealthmode\s+(?:on|off)|listapps|add\s+"[^"]+"|remove\s+"[^"]+")$/ | ||
// Regex para validar comandos de Bluetooth no macOS | ||
@@ -4,0 +4,0 @@ export const macOSBluetoothRegex = /^sudo\s+(?:defaults\s+write\s+\/Library\/Preferences\/com\.apple\.Bluetooth\.plist\s+ControllerPowerState\s+-int\s+[01]|killall\s+-HUP\s+bluetoothd)$/; |
// Regex para validar comandos de Firewall no windows | ||
export const windowsFirewallRegex = /^netsh\s+advfirewall\s+(set\s+(allprofiles|currentprofile)\s+state\s+(on|off)|firewall\s+(add|delete)\s+rule\s+name="[\w\s\-]+"(\s+dir=(in|out))?(\s+action=(allow|block))?(\s+protocol=(TCP|UDP))?(\s+localport=\d+)?(\s+program="[\w:\\\\]+"|$))$/; | ||
//export const windowsFirewallRegex = /^netsh\s+advfirewall\s+(set\s+(allprofiles|currentprofile)\s+state\s+(on|off)|firewall\s+(add|delete)\s+rule\s+name="[\w\s\-]+"(\s+dir=(in|out))?(\s+action=(allow|block))?(\s+protocol=(TCP|UDP))?(\s+localport=\d+)?(\s+program="[\w:\\\\]+"|$))$/; | ||
export const windowsFirewallRegex = /^netsh\s+advfirewall\s+(?:(?:set\s+(?:allprofiles|currentprofile)\s+(?:state\s+(?:on|off)|logging\s+(?:droppedpackets\s+enable|filename\s+"[^"]+")))|(?:firewall\s+(?:add|delete|show)\s+rule\s+(?:name="[\w\s\-]+"|name=all)(?:\s+dir=(?:in|out))?(?:\s+action=(?:allow|block))?(?:\s+protocol=(?:TCP|UDP))?(?:\s+localport=\d+)?(?:\s+program="[^"]+"|$)?(?:\s+enable=yes)?(?:\s+\|\s+findstr\s+Group)?)|(?:show\s+currentprofile)|(?:(?:export|import)\s+"[^"]+"))$/; | ||
// Regex para validar comandos Bluetooth no windows | ||
export const windowsBluetoothRegex = /^(Enable|Disable)-NetAdapter\s+-Name\s+"Bluetooth Network Connection"$|^Get-PnpDevice\s+\|\s+Where-Object\s+{\s+\$_.FriendlyName\s+-like\s+"\*Bluetooth\*"\s+}$/; | ||
//export const windowsBluetoothRegex = /^(Enable|Disable)-NetAdapter\s+-Name\s+"Bluetooth Network Connection"$|^Get-PnpDevice\s+\|\s+Where-Object\s+{\s+\$_.FriendlyName\s+-like\s+"\*Bluetooth\*"\s+}$/; | ||
export const windowsBluetoothRegex = /^(?:(?:Enable|Disable)-NetAdapter\s+-Name\s+"Bluetooth Network Connection"|Get-PnpDevice\s+\|\s+Where-Object\s+{\s+\$_\.FriendlyName\s+-like\s+"\*Bluetooth\*"\s+}|Set-BluetoothSettings\s+-AllowReceiveFiles\s+\$(?:true|false))$/; | ||
// Regex para validar comandos USB no windows | ||
@@ -6,0 +8,0 @@ export const windowsUSBRegexManage = /^Set-ItemProperty\s+-Path\s+"HKLM:\\SYSTEM\\CurrentControlSet\\Services\\USBSTOR"\s+-Name\s+"Start"\s+-Value\s+[34]$/; |
54963
475