Compare commits

..
Author SHA1 Message Date
ShareVB ec6c5b4066 fix: lint 2024-07-12 23:24:09 +02:00
ShareVB c3c956bb6e fix: deps 2024-07-12 23:15:56 +02:00
ShareVB 80d87cb290 feat: disable some built-in regex 2024-07-12 23:13:20 +02:00
ShareVB 933d824083 feat: enhance cleaned PII and custom regexes 2024-07-07 22:59:31 +02:00
ShareVB e6e51cf1c4 chore: fix strange corepack message
Fix corepack claiming strange thing : UsageError: This project is configured to use yarn because /home/runner/work/it-tools/it-tools/package.json has a "packageManager" field
2024-07-07 14:26:16 +02:00
sharevb 747a7c81c2 feat(new tool): Sensitive data masker
Fix #765
2024-07-07 14:25:25 +02:00
11 changed files with 216 additions and 234 deletions

No files matched your search

+1 -12
View File
@@ -55,8 +55,6 @@ declare module '@vue/runtime-core' {
ColoredCard: typeof import('./src/components/ColoredCard.vue')['default']
CommandPalette: typeof import('./src/modules/command-palette/command-palette.vue')['default']
CommandPaletteOption: typeof import('./src/modules/command-palette/components/command-palette-option.vue')['default']
CommonRegex: typeof import('./src/tools/common-regex-memo/common-regex.md')['default']
CommonRegexMemo: typeof import('./src/tools/common-regex-memo/common-regex-memo.vue')['default']
CrontabGenerator: typeof import('./src/tools/crontab-generator/crontab-generator.vue')['default']
CSelect: typeof import('./src/ui/c-select/c-select.vue')['default']
'CSelect.demo': typeof import('./src/ui/c-select/c-select.demo.vue')['default']
@@ -132,24 +130,14 @@ declare module '@vue/runtime-core' {
NCode: typeof import('naive-ui')['NCode']
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
NDivider: typeof import('naive-ui')['NDivider']
NEllipsis: typeof import('naive-ui')['NEllipsis']
NForm: typeof import('naive-ui')['NForm']
NFormItem: typeof import('naive-ui')['NFormItem']
NGi: typeof import('naive-ui')['NGi']
NGrid: typeof import('naive-ui')['NGrid']
NH1: typeof import('naive-ui')['NH1']
NH3: typeof import('naive-ui')['NH3']
NIcon: typeof import('naive-ui')['NIcon']
NInputNumber: typeof import('naive-ui')['NInputNumber']
NLabel: typeof import('naive-ui')['NLabel']
NLayout: typeof import('naive-ui')['NLayout']
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
NMenu: typeof import('naive-ui')['NMenu']
NScrollbar: typeof import('naive-ui')['NScrollbar']
NSlider: typeof import('naive-ui')['NSlider']
NSpin: typeof import('naive-ui')['NSpin']
NSwitch: typeof import('naive-ui')['NSwitch']
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default']
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']
@@ -165,6 +153,7 @@ declare module '@vue/runtime-core' {
RouterView: typeof import('vue-router')['RouterView']
RsaKeyPairGenerator: typeof import('./src/tools/rsa-key-pair-generator/rsa-key-pair-generator.vue')['default']
SafelinkDecoder: typeof import('./src/tools/safelink-decoder/safelink-decoder.vue')['default']
SensitiveDataMasker: typeof import('./src/tools/sensitive-data-masker/sensitive-data-masker.vue')['default']
SlugifyString: typeof import('./src/tools/slugify-string/slugify-string.vue')['default']
SpanCopyable: typeof import('./src/components/SpanCopyable.vue')['default']
SqlPrettify: typeof import('./src/tools/sql-prettify/sql-prettify.vue')['default']
+2
View File
@@ -55,6 +55,7 @@
"cron-validator": "^1.3.1",
"cronstrue": "^2.26.0",
"crypto-js": "^4.1.1",
"data-guardian": "^1.1.3",
"date-fns": "^2.29.3",
"dompurify": "^3.0.6",
"emojilib": "^3.0.10",
@@ -64,6 +65,7 @@
"highlight.js": "^11.7.0",
"iarna-toml-esm": "^3.0.5",
"ibantools": "^4.3.3",
"ip-regex": "^5.0.0",
"js-base64": "^3.7.6",
"json5": "^2.2.3",
"jwt-decode": "^3.1.2",
+26 -9
View File
@@ -65,6 +65,9 @@ dependencies:
crypto-js:
specifier: ^4.1.1
version: 4.1.1
data-guardian:
specifier: ^1.1.3
version: 1.1.3
date-fns:
specifier: ^2.29.3
version: 2.29.3
@@ -92,6 +95,9 @@ dependencies:
ibantools:
specifier: ^4.3.3
version: 4.3.3
ip-regex:
specifier: ^5.0.0
version: 5.0.0
js-base64:
specifier: ^3.7.6
version: 3.7.7
@@ -3354,7 +3360,7 @@ packages:
dependencies:
'@unhead/dom': 0.5.1
'@unhead/schema': 0.5.1
'@vueuse/shared': 10.8.0(vue@3.3.4)
'@vueuse/shared': 10.11.0(vue@3.3.4)
unhead: 0.5.1
vue: 3.3.4
transitivePeerDependencies:
@@ -3987,19 +3993,19 @@ packages:
- vue
dev: false
/@vueuse/shared@10.3.0(vue@3.3.4):
resolution: {integrity: sha512-kGqCTEuFPMK4+fNWy6dUOiYmxGcUbtznMwBZLC1PubidF4VZY05B+Oht7Jh7/6x4VOWGpvu3R37WHi81cKpiqg==}
/@vueuse/shared@10.11.0(vue@3.3.4):
resolution: {integrity: sha512-fyNoIXEq3PfX1L3NkNhtVQUSRtqYwJtJg+Bp9rIzculIZWHTkKSysujrOk2J+NrRulLTQH9+3gGSfYLWSEWU1A==}
dependencies:
vue-demi: 0.14.5(vue@3.3.4)
vue-demi: 0.14.8(vue@3.3.4)
transitivePeerDependencies:
- '@vue/composition-api'
- vue
dev: false
/@vueuse/shared@10.8.0(vue@3.3.4):
resolution: {integrity: sha512-dUdy6zwHhULGxmr9YUg8e+EnB39gcM4Fe2oKBSrh3cOsV30JcMPtsyuspgFCUo5xxFNaeMf/W2yyKfST7Bg8oQ==}
/@vueuse/shared@10.3.0(vue@3.3.4):
resolution: {integrity: sha512-kGqCTEuFPMK4+fNWy6dUOiYmxGcUbtznMwBZLC1PubidF4VZY05B+Oht7Jh7/6x4VOWGpvu3R37WHi81cKpiqg==}
dependencies:
vue-demi: 0.14.7(vue@3.3.4)
vue-demi: 0.14.5(vue@3.3.4)
transitivePeerDependencies:
- '@vue/composition-api'
- vue
@@ -4719,6 +4725,11 @@ packages:
resolution: {integrity: sha512-4FbVrHDwfOASx7uQVxeiCTo7ggSdYZbqs8lH+WU6ViypPlDbe9y6IP5VVUDQBv9DcnyaiPT5XT0UWHgJ64zLeQ==}
dev: false
/data-guardian@1.1.3:
resolution: {integrity: sha512-8M9KHTopFp3MXo7NelcmF+8L77S5jeDy3Uv4RWuYIQSaBZTawvY6W3ad/eLe8db2FcLPoC44DHJb4zWNcpoueQ==}
engines: {node: '>=12'}
dev: false
/data-uri-to-buffer@4.0.1:
resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==}
engines: {node: '>= 12'}
@@ -6188,6 +6199,11 @@ packages:
jsbn: 1.1.0
dev: false
/ip-regex@5.0.0:
resolution: {integrity: sha512-fOCG6lhoKKakwv+C6KdsOnGvgXnmgfmp0myi3bcNwj3qfwPAxRKWEuFhvEFF7ceYIz6+1jRZ+yguLFAmUNPEfw==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
dev: false
/is-alphabetical@1.0.4:
resolution: {integrity: sha512-DwzsA04LQ10FHTZuL0/grVDk4rFoVH1pjAToYwBrHSxcrBIGQuXrQMtD5U1b0U2XVgKZCTLLP8u2Qxqhy3l2Vg==}
dev: true
@@ -9158,8 +9174,8 @@ packages:
vue: 3.3.4
dev: false
/vue-demi@0.14.7(vue@3.3.4):
resolution: {integrity: sha512-EOG8KXDQNwkJILkx/gPcoL/7vH+hORoBaKgGe+6W7VFMvCYJfmF2dGbvgDroVnI8LU7/kTu8mbjRZGBU1z9NTA==}
/vue-demi@0.14.8(vue@3.3.4):
resolution: {integrity: sha512-Uuqnk9YE9SsWeReYqK2alDI5YzciATE0r2SkA6iMAtuXvNTMNACJLJEXNXaEy94ECuBe4Sk6RzRU80kjdbIo1Q==}
engines: {node: '>=12'}
hasBin: true
requiresBuild: true
@@ -9449,6 +9465,7 @@ packages:
/workbox-google-analytics@7.0.0:
resolution: {integrity: sha512-MEYM1JTn/qiC3DbpvP2BVhyIH+dV/5BjHk756u9VbwuAhu0QHyKscTnisQuz21lfRpOwiS9z4XdqeVAKol0bzg==}
deprecated: It is not compatible with newer versions of GA starting with v4, as long as you are using GAv3 it should be ok, but the package is not longer being maintained
dependencies:
workbox-background-sync: 7.0.0
workbox-core: 7.0.0
@@ -1,25 +0,0 @@
<script setup lang="ts">
import { useThemeVars } from 'naive-ui';
import Memo from './common-regex.md';
const themeVars = useThemeVars();
</script>
<template>
<div>
<Memo style="overflow-x: auto;" />
</div>
</template>
<style lang="less" scoped>
::v-deep(pre) {
margin: 0;
padding: 15px 22px;
background-color: v-bind('themeVars.cardColor');
border-radius: 4px;
white-space: pre-wrap;
}
::v-deep(a) {
color: v-bind('themeVars.textColor3');
}
</style>
-174
View File
@@ -1,174 +0,0 @@
### Commonly used Regex
#### 1\. Digits
* [Whole Numbers](https://www.regexpal.com/?fam=104020) – `/^\d+$/`
* [Decimal Numbers](https://www.regexpal.com/?fam=104021) – `/^\d*\.\d+$/`
* [Whole + Decimal Numbers](https://www.regexpal.com/?fam=104022) – `/^\d*(\.\d+)?$/`
* [Negative, Positive Whole + Decimal Numbers](https://www.regexpal.com/?fam=104023) – `/^-?\d*(\.\d+)?$/`
* [Whole + Decimal + Fractions](https://www.regexpal.com/94462) – `/[-]?[0-9]+[,.]?[0-9]*([\/][0-9]+[,.]?[0-9]*)*/`
#### 2\. Alphanumeric Characters
* [Alphanumeric without space](https://www.regexpal.com/?fam=104024) – `/^[a-zA-Z0-9]*$/`
* [Alphanumeric with space](https://www.regexpal.com/?fam=104025) – `/^[a-zA-Z0-9 ]*$/`
#### 3\. Email
* [Common email Ids](https://www.regexpal.com/?fam=104026) – `/^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6})*$/`
* [Uncommon email ids](https://www.regexpal.com/?fam=104027) – `/^([a-z0-9_\.\+-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/`
#### 4\. Password Strength
* [Complex](https://www.regexpal.com/?fam=104028): Should have 1 lowercase letter, 1 uppercase letter, 1 number, 1 special character and be at least 8 characters long
/(?=(.\*\[0-9\]))(?=.\*\[\\!@#$%^&\*()\\\\\[\\\]{}\\-\_+=~\`|:;"'<>,./?\])(?=.\*\[a-z\])(?=(.\*\[A-Z\]))(?=(.\*)).{8,}/
* [Moderate](https://www.regexpal.com/?fam=104029): Should have 1 lowercase letter, 1 uppercase letter, 1 number, and be at least 8 characters long
/(?=(.\*\[0-9\]))((?=.\*\[A-Za-z0-9\])(?=.\*\[A-Z\])(?=.\*\[a-z\]))^.{8,}$/
#### 5\. Username
* [Alphanumeric string](https://www.regexpal.com/?fam=104030) that may include \_ and – having a length of 3 to 16 characters – `/^[a-z0-9_-]{3,16}$/`
#### 6\. URL
* Include [http(s) Protocol](https://www.regexpal.com/?fam=104034)
```
/https?:\\/\\/(www\\.)?\[-a-zA-Z0-9@:%.\_\\+~#=\]{2,256}\\.\[a-z\]{2,6}\\b(\[-a-zA-Z0-9@:%\_\\+.~#()?&//=\]\*)/
```
* [Protocol Optional](https://www.regexpal.com/?fam=104035)
```
/(https?:\\/\\/)?(www\\.)?\[-a-zA-Z0-9@:%.\_\\+~#=\]{2,256}\\.\[a-z\]{2,6}\\b(\[-a-zA-Z0-9@:%\_\\+.~#?&//=\]\*)/
```
#### 7\. IP Address
* [IPv4 address](https://www.regexpal.com/?fam=104036)
```
/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/
```
* [IPv6 address](https://www.regexpal.com/?fam=104037)
```
/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/
```
* Both [IPv4, IPv6 addresses](https://www.regexpal.com/?fam=104038)
```
/((^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$)|(^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$))/`
```
#### 8\. Dates
* Date Format [YYYY-MM-dd](https://www.regexpal.com/?fam=104039) using separator `-`
`/([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))/`
* Date Format [dd-MM-YYYY](https://regexr.com/?346hf) using separators `-` or `.` or `/`
`/^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/`
* Date Format [dd-mmm-YYYY](https://regexr.com/39tr1) using separators `-` or `.` or `/`
`/^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]|(?:Jan|Mar|May|Jul|Aug|Oct|Dec)))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2]|(?:Jan|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)(?:0?2|(?:Feb))\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9]|(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep))|(?:1[0-2]|(?:Oct|Nov|Dec)))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/`
#### 9\. Time
* Time Format [HH:MM 12-hour](https://www.regexpal.com/?fam=104040), optional leading 0
`/^(0?[1-9]|1[0-2]):[0-5][0-9]$/`
* Time Format HH:MM 12-hour, optional leading 0, **[Meridiems (AM/PM)](https://www.regexpal.com/?fam=104041)**
`/((1[0-2]|0?[1-9]):([0-5][0-9]) ?([AaPp][Mm]))/`
* Time Format [HH:MM 24-hour](https://www.regexpal.com/?fam=104042) with leading 0
`/^(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/`
* Time Format [HH:MM 24-hour, optional leading 0](https://www.regexpal.com/?fam=104043)
`/^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/`
* Time Format [HH:MM:SS 24-hour](https://www.regexpal.com/?fam=104044)
`/(?:[01]\d|2[0123]):(?:[012345]\d):(?:[012345]\d)/`
#### 10\. HTML Tags
* [Elements with Attributes](https://www.regexpal.com/95941) `/<\/?[\w\s]*>|<.+[\W]>/`
#### 11\. Javascript Handlers
* [Inline JS handler](https://www.regexpal.com/?fam=104055) `/\bon\w+=\S+(?=.*>)/`
* [Inline JS handler with element](https://www.regexpal.com/94641) `/(?:<[^>]+\s)(on\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|[>"']))+.)["']?/`
#### 12\. Slug
* [Slug](https://www.regexpal.com/?fam=104056) `/^[a-z0-9]+(?:-[a-z0-9]+)*$/`
#### 13\. Match Duplicates in a String
* [Search Duplicates](https://www.regexpal.com/?fam=104060) `/(\b\w+\b)(?=.*\b\1\b)/`
#### 14\. Phone Numbers
* [International Phone Numbers](https://www.regexpal.com/?fam=99127) – with optional country code/extension
```
`/* International Phone Numbers */`
/^(?:(?:\(?(?:00|\+)([1-4]\d\d|[1-9]\d?)\)?)?[\-\.\ \\\/]?)?((?:\(?\d{1,}\)?[\-\.\ \\\/]?){0,})(?:[\-\.\ \\\/]?(?:``#|ext\.?|extension|x)[\-\.\ \\\/]?(\d+))?$/
```
_Note:_ Use regex for validating phone numbers **only** if you don’t have the choice to use a library. There are [several libraries](https://stackoverflow.com/a/15644461/4717533) that handle phone numbers more accurately and should be used instead.
#### 15\. File Path
* [File Path with Filename and extension](https://www.regexpal.com/?fam=104047)
```
/((\\/|\\\\|\\/\\/|https?:\\\\\\\\|https?:\\/\\/)\[a-z0-9 \_@\\-^!#$%&+={}.\\/\\\\\\\[\\\]\]+)+\\.\[a-z\]+$/
```
* File Path with optional Filename, extension
```
/^(.+)/(\[^/\]+)$/
```
* [File Name with extension](https://www.regexpal.com/?fam=104048) having 3 chars
```
/^\[\\w,\\s-\]+\\.\[A-Za-z\]{3}$/
```
### Additional Regexes
#### 1\. Zip codes
There is **NO** single Regex that can handle all zip codes given that zip codes around the world do not follow a common pattern. Here is a [list](https://stackoverflow.com/a/7185241/4717533) that contains Regex specific to each country.
#### 2\. Payment Validation
Here is a [link](https://www.regular-expressions.info/creditcard.html) that contains regex for validating leading Credit cards like Visa, Mastercard and so on.
#### 3\. Identity Documents
* Social Security Number – [Ref](https://www.codeproject.com/Articles/651609/Validating-Social-Security-Numbers-through-Regular)
```
/\* can use either hypen(-) or space( ) character as separator \*/
/^((?!219-09-9999|078-05-1120)(?!666|000|9\\d{2})\\d{3}-(?!00)\\d{2}-(?!0{4})\\d{4})|((?!219 09 9999|078 05 1120)(?!666|000|9\\d{2})\\d{3} (?!00)\\d{2} (?!0{4})\\d{4})|((?!219099999|078051120)(?!666|000|9\\d{2})\\d{3}(?!00)\\d{2}(?!0{4})\\d{4})$/
```
* Passport – `/^[A-PR-WY][1-9]\d\s?\d{4}[1-9]$/`
#### References
* [https://www.codeproject.com/validate-passport-number](https://www.codeproject.com/Questions/1046445/How-to-validate-passport-number-using-javascript)
* [https://gist.github.com/](https://gist.github.com/nerdsrescueme/1237767)
* [https://code.tutsplus.com/regular-expressions](https://code.tutsplus.com/tutorials/8-regular-expressions-you-should-know--net-6149)
* [https://www.regular-expressions.info](https://www.regular-expressions.info/)
* [http://www.regexlib.com/](http://www.regexlib.com/)
* [https://projects.lukehaas.me/regexhub/](https://projects.lukehaas.me/regexhub/)
* [http://wiki.zoolz.com/commonly-used-regular-expressions/](http://wiki.zoolz.com/commonly-used-regular-expressions/)
* [https://www.smashingmagazine.com/advanced-regular-expressions/](https://www.smashingmagazine.com/2009/05/introduction-to-advanced-regular-expressions/)
-12
View File
@@ -1,12 +0,0 @@
import { FileText } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Common Regex Cheatsheet',
path: '/common-regex-memo',
description: 'Cheatsheet for common regex patterns',
keywords: ['common', 'regex', 'memo', 'cheatsheet'],
component: () => import('./common-regex-memo.vue'),
icon: FileText,
createdAt: new Date('2024-05-11'),
});
+2 -2
View File
@@ -6,7 +6,7 @@ import { tool as asciiTextDrawer } from './ascii-text-drawer';
import { tool as textToUnicode } from './text-to-unicode';
import { tool as safelinkDecoder } from './safelink-decoder';
import { tool as commonRegexMemo } from './common-regex-memo';
import { tool as sensitiveDataMasker } from './sensitive-data-masker';
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
import { tool as numeronymGenerator } from './numeronym-generator';
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -149,7 +149,6 @@ export const toolsByCategory: ToolCategory[] = [
dockerRunToDockerComposeConverter,
xmlFormatter,
yamlViewer,
commonRegexMemo,
],
},
{
@@ -174,6 +173,7 @@ export const toolsByCategory: ToolCategory[] = [
textDiff,
numeronymGenerator,
asciiTextDrawer,
sensitiveDataMasker,
],
},
{
+12
View File
@@ -0,0 +1,12 @@
import { ShieldLock } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Sensitive data masker',
path: '/sensitive-data-masker',
description: 'Clean sensitive data from textual content (ie logs)',
keywords: ['sensitive', 'data', 'masker', 'obfuscator', 'clean', 'log'],
component: () => import('./sensitive-data-masker.vue'),
icon: ShieldLock,
createdAt: new Date('2024-06-16'),
});
@@ -0,0 +1,75 @@
import { describe, expect, it } from 'vitest';
import { maskSensitiveData } from './sensitive-data-masker.service';
describe('sensitive-data-masker', () => {
describe('maskSensitiveData', () => {
const data = `{
email: 'john.doe@example.com',
creditCard: '1234 5678 9000 9876',
id: '3f8a43fd-6489-4ec7-bd55-7a1ba172d77b',
name: 'John',
surname: 'Doe',
phone: '+358 40 1234567',
url: 'truc.google.com',
ip4: '83.24.45.56',
ip6: '2001:db8:0:85a3:0:0:ac1f:8001',
mac: '3D:F2:C9:A6:B3:4F',
token: 'eyJhbGciOiJIUzI1NiJ9.ew0KICAic3ViIjogIjEyMzQ1Njc4OTAiLA0KICAibmFtZSI6ICJBbGV4IEtvemxvdiIsDQogICJpYXQiOiAxNTE2MjM5MDIyDQp9.PNKysYFTCenU5bekHCmwIxCUXoYG41H_xc3uN3ZF_b8',
}`;
it('should maks sensitive data', () => {
expect(maskSensitiveData({
value: data,
})).toBe(`{
email: 'jo****************om',
creditCard: '12***************76',
id: '3f********************************7b',
name: 'John',
surname: 'Doe',
phone: '+3***********67',
url: 'tr***********om',
ip4: '83*******56',
ip6: '20*************************01',
mac: '3D*************4F',
token: 'ey*****************************************************************************************************************************************************************b8',
}`);
});
it('should maks sensitive data (with custom regex)', () => {
expect(maskSensitiveData({
value: data,
customRegex: 'John\nDoe',
})).toBe(`{
email: 'jo****************om',
creditCard: '12***************76',
id: '3f********************************7b',
name: '****',
surname: '***',
phone: '+3***********67',
url: 'tr***********om',
ip4: '83*******56',
ip6: '20*************************01',
mac: '3D*************4F',
token: 'ey*****************************************************************************************************************************************************************b8',
}`);
});
it('should maks sensitive data (with excluded matchers)', () => {
expect(maskSensitiveData({
value: data,
excludedMatchers: ['mac', 'ipv4'],
})).toBe(`{
email: 'jo****************om',
creditCard: '12***************76',
id: '3f********************************7b',
name: 'John',
surname: 'Doe',
phone: '+3***********67',
url: 'tr***********om',
ip4: '83.24.45.56',
ip6: '20*************************01',
mac: '3D:F2:C9:A6:B3:4F',
token: 'ey*****************************************************************************************************************************************************************b8',
}`);
});
});
});
@@ -0,0 +1,34 @@
import { type SensitiveContentKey, maskString } from 'data-guardian';
import ipRegex from 'ip-regex';
const jwtRegex = /\b([a-zA-Z0-9_=]{5,})\.([a-zA-Z0-9_=]{5,})\.([a-zA-Z0-9_\-\+\/=]{5,})\b/g;
const phoneRegex = /(?:(\+\d{1,4})[-.\s]?)(?:[(](\d{1,3})[)][-.\s]?)?(\d{1,4})[-.\s]?(\d{1,4})[-.\s]?(\d{1,9})\b/g;
const macRegex = /\b([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})\b/g;
const urlWithOrWithoutPrefixRegex = /\b(https?:\/\/)?(www\.)?[a-zA-Z0-9@:%._+~#=-]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&\/=]*)\b/g;
export type MatcherNames = 'uuid' | 'creditCard' | 'ssn' | 'url' | 'ipv4' | 'email' | 'passwordInUri' | 'mac' | 'ipv6' | 'urlWithOrWithoutPrefix' | 'jwt' | 'phone';
export function maskSensitiveData({
value,
customRegex = '',
excludedMatchers = [],
}: {
value: string
customRegex?: string
excludedMatchers?: Array<MatcherNames>
}) {
excludedMatchers = excludedMatchers || [];
const emptyRegex = /(?:)/g;
return maskString(value, null as never, {
customRegex: new RegExp((customRegex || '').split('\n').map(line => `(${line})`).join('|'), 'gi'),
macRegex: excludedMatchers.includes('mac') ? emptyRegex : macRegex,
ipv6Regex: excludedMatchers.includes('ipv6') ? emptyRegex : ipRegex.v6({ includeBoundaries: false }),
urlWithOrWithoutPrefixRegex: excludedMatchers.includes('urlWithOrWithoutPrefix') ? emptyRegex : urlWithOrWithoutPrefixRegex,
jwtRegex: excludedMatchers.includes('jwt') ? emptyRegex : jwtRegex,
phoneRegex: excludedMatchers.includes('phone') ? emptyRegex : phoneRegex,
}, {
excludeMatchers: [...excludedMatchers, ...[
'passwordMention', 'password', 'passwordSubstring',
]] as SensitiveContentKey[],
});
}
@@ -0,0 +1,64 @@
<script setup lang="ts">
import { type MatcherNames, maskSensitiveData } from './sensitive-data-masker.service';
import { withDefaultOnError } from '@/utils/defaults';
const defaultValue = `{
email: 'john.doe@example.com',
creditCard: '1234 5678 9000 9876',
id: '3f8a43fd-6489-4ec7-bd55-7a1ba172d77b',
name: 'John',
surname: 'Doe',
phone: '+358 40 1234567',
url: 'truc.google.com',
ip4: '83.24.45.56',
ip6: '2001:db8:0:85a3:0:0:ac1f:8001',
mac: '3D:F2:C9:A6:B3:4F',
token: 'eyJhbGciOiJIUzI1NiJ9.ew0KICAic3ViIjogIjEyMzQ1Njc4OTAiLA0KICAibmFtZSI6ICJBbGV4IEtvemxvdiIsDQogICJpYXQiOiAxNTE2MjM5MDIyDQp9.PNKysYFTCenU5bekHCmwIxCUXoYG41H_xc3uN3ZF_b8',
}`;
const customRegex = useStorage('sensitive-data:regex', '');
const excludedMatchers = useStorage('sensitive-data:exclude', [] as string[]);
const allMatchers = [
'uuid', 'creditCard', 'ssn', 'url', 'ipv4', 'email',
'passwordInUri', 'mac', 'ipv6', 'urlWithOrWithoutPrefix',
'jwt', 'phone'];
function transformer(value: string) {
return withDefaultOnError(() => maskSensitiveData({
value,
customRegex: customRegex.value,
excludedMatchers: excludedMatchers.value as MatcherNames[],
}), '');
}
</script>
<template>
<div style="max-width: 600px;">
<c-input-text
v-model:value="customRegex"
label="Your custom cleaning regex(es) (case insensitive):"
placeholder="Your custom cleaning regex(es)"
raw-text
multiline
rows="4"
mb-2
/>
<n-select
v-model:value="excludedMatchers"
placeholder="No Fallback"
multiple
:fallback-option="false"
:options="allMatchers.map(v => ({ label: v, value: v }))"
mb-2
/>
<format-transformer
input-label="Your log/textual data:"
:input-default="defaultValue"
input-placeholder="Paste your log/textual data here..."
output-label="Cleaned version:"
:transformer="transformer"
/>
</div>
</template>