
Research
Supply Chain Attack on Axios Pulls Malicious Dependency from npm
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.
Parsa ya data! An all purpose module to parse, sanitize, extract and validate data.
parsa is an all purpose module which can parse, validate, extract and more!
parsa is only 8KB compare to Moment.js which is ~51KB. This is handy if using in the browser.
<script type="text/javascript" src="dist/parsa.min.js" charset="utf-8"></script>
<script>
console.log('parseDate: 20121125 = ', parsa.parseDate('20121125', 'YYYYMMDD'));
</script>
<script type="text/javascript" src="https://cdn.rawgit.com/mrvautin/parsa/dist/parsa.min.js" charset="utf-8"></script>
const parsa = require('parsa');
parsa.parseDate('20121125', 'YYYYMMDD');
npm test
gulp deploy
The parseDate function takes a date string and format string parameters and returns a Javascript Date() Object.
parsa.parseDate('20121125', 'YYYYMMDD')
Returns:
Sun Nov 25 2012 01:00:00 GMT+0100 (CET)
YYYYMMDDYYYYDDMMDDMMYYYYMMDDYYYYMMDDYYDDMMYYMM/DD/YYYYDD/MM/YYYYYYYY/DD/MMDD-MM-YYYYMM-DD-YYYYYYYY-DD-MMYYYY-MM-DDDD MM YYYYMM DD YYYYYYYY MM DDYYYYMMDD HH:MMYYYYDDMM HH:MMYYYYMMDD HH:MM:SSYYYYDDMM HH:MM:SSYYYY-DD-MM HH:MMYYYY-MM-DD HH:MMYYYY/MM/DD HH:MMYYYY/DD/MM HH:MMDo MMMM YYYYDo, MMMM, YYYYMM MMMM YYYYThe validateIp function takes an IP address string and returns a boolean value whether it is valid or invalid.
parsa.validateIp('115.42.150.37')
Returns:
true
The validateIpv6 function takes an IP address string and returns a boolean value whether it is valid or invalid.
parsa.validateIpv6('2001:db8:3:4::')
Returns:
true
The parseQuery function takes a URL and returns an Object of the Query string parameters.
parsa.parseQuery('http://example.com/product.php?category=4&product_id=2140&query=lcd+tv')
Returns:
{
"category": "4",
"product_id": "2140",
"query": "lcd+tv"
}
The parseUrl function takes a URL and returns an Object of the URL section.
parsa.parseQuery('https://www.google.com:80/dir/1/2/search.html?arg=0-a&arg1=1-b&arg3-c#hash')
Returns:
{
"url": "https://www.google.com:80/dir/1/2/search.html?arg=0-a&arg1=1-b&arg3-c#hash",
"protocol": "https",
"host": "www.google.com",
"port": ":80",
"path": "/dir/1/2/",
"file": "search.html",
"query": "?arg=0-a&arg1=1-b&arg3-c",
"hash": "#hash"
}
The validateUrl function takes a URL and returns a boolean result.
parsa.validateUrl('https://www.google.com')
Returns:
true
The validateEmail function takes a email address string and returns a boolean value whether it is valid or invalid.
parsa.validateEmail('hi@gmail.com')
Returns:
true
The extractNum function takes a string and returns an array of numbers/decimals found in that string.
parsa.extractNum('This is a10 string with3.14decimals6 and numbers.')
Returns:
[
'10',
'3.14',
'6'
]
The extractWords function takes a string and an array of words and returns an array of matched words in the string.
var words = ['this', 'some', 'words'];
parsa.extractWords('thisadkfdlfkdisdsstringdfjdkwithdkfdfkldsomefdfdfkdflkwordsjfgjkfg', words)
Returns:
[
'this',
'some',
'words'
]
The extractPhone function takes a string and returns an array of matched phone numbers.
parsa.extractPhone('thisadkfdlfkdisdsstringdfjdkwithdkfdfkldsomefdfdfkdflkwordsjfgjkfg', words)
Returns:
[
'this',
'some',
'words'
]
The securePassword function takes a password string returns a boolean whether it's a secure password.
parsa.securePassword('Testing193!')
Password requirements are set to standard defaults:
Returns:
true
The removeAlpha function takes a string and removes all non number characters.
parsa.removeAlpha('some1number')
Returns:
1
The removeNumeric function takes a string and removes all numbers.
parsa.removeNumeric('some1number')
Returns:
somenumber
The firstUppercase function takes a string and makes the first character of each word uppercase.
parsa.firstUppercase('this is a test string')
Returns:
This Is A Test String
The validateObject function takes an Object and a Schema and returns a validation result with any errors.
Each schema validation requires a name and a rules array. The name property refers to the key in the Object being supplied.
isAlphaisNumericisStringminLengthmaxLengthisBetweenLengthisObjectisArrayisRequiredsecurePasswordlet object = {
"test_number": 1234,
"test_string": 'abcdefg',
"test_array": [1, 2, 3],
"test_required": '',
"test_length": 'I am a long string'
};
let schema = [
{
"name": "test_number",
"rules": [
'isNumeric'
]
},
{
"name": "test_string",
"rules": [
'isString',
]
},
{
"name": "test_array",
"rules": [
'isArray'
]
},
{
"name": "test_required",
"rules": [
'isRequired'
]
},
{
"name": "test_length",
"rules": [
'minLength|5',
'maxLength|25'
]
}
];
Note: when using a schema validation which requires multiple arguments other than the value (Eg:
minLength,isBetweenLengthetc) you pass arguments using the|character as a separator. For example:isBetweenLengthwould look like:isBetweenLength|0|16which would validate values between 0 and 16 characters in length.
parsa.validateObject(schema, object)
Returns:
With errors
{
errors: [
{
property: 'test_string',
message: 'Value is greater than the maximum length'
},
{
property: 'test_required',
message: 'Value is required'
}
],
result: false
}
Without errors
{
errors: [],
result: true
}
The isAlpha function takes a value and returns a boolean whether it contains only alpha characters.
parsa.isAlpha('this is a test string')
Returns:
true
The isNumeric function takes value and returns a boolean whether it contains only alpha numbers.
parsa.isNumeric(1234)
Returns:
true
The isObject function takes value and returns a boolean whether it is a Object.
parsa.isObject({"test": "Object"})
Returns:
true
The isArray function takes value and returns a boolean whether it is a Array.
parsa.isArray(['abcd', '1234'])
Returns:
true
The isString function takes value and returns a boolean whether it is a String.
parsa.isString('fkdlfkdl3233')
Returns:
true
The isDefined function takes value and returns a boolean whether the value is null or undefined.
parsa.isDefined('')
Returns:
false
The isFunction function takes value and returns a boolean whether it is a Function.
parsa.isFunction(function test(){})
Returns:
true
The minLength function takes value and a desired length and returns a boolean whether it's is greater than supplied value.
parsa.minLength('23434fdfdfd', 5)
Returns:
true
The maxLength function takes value and a desired length and returns a boolean whether it's is less than supplied value.
parsa.maxLength('23434fdfdfd', 5)
Returns:
false
The isBetweenLength function takes value, a min length and a max length and returns a boolean whether the value is between the range.
parsa.maxLength('23434fdf', 5, 10)
Returns:
true
FAQs
Parsa ya data! An all purpose module to parse, sanitize, extract and validate data.
We found that parsa demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.

Security News
TeamPCP is partnering with ransomware group Vect to turn open source supply chain attacks on tools like Trivy and LiteLLM into large-scale ransomware operations.