Gathering detailed insights and metrics for undefsafe
Gathering detailed insights and metrics for undefsafe
Gathering detailed insights and metrics for undefsafe
Gathering detailed insights and metrics for undefsafe
Simple *function* for retrieving deep object properties without getting "Cannot read property 'X' of undefined"
npm install undefsafe
99.9
Supply Chain
85.8
Quality
75.7
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
71 Stars
34 Commits
9 Forks
6 Watching
3 Branches
3 Contributors
Updated on 10 Mar 2024
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-28.6%
966,276
Compared to previous day
Last week
-6.3%
6,773,900
Compared to previous week
Last month
6.3%
28,886,419
Compared to previous month
Last year
11.4%
286,284,387
Compared to previous year
3
Simple function for retrieving deep object properties without getting "Cannot read property 'X' of undefined"
Can also be used to safely set deep values.
1var object = { 2 a: { 3 b: { 4 c: 1, 5 d: [1,2,3], 6 e: 'remy' 7 } 8 } 9}; 10 11console.log(undefsafe(object, 'a.b.e')); // "remy" 12console.log(undefsafe(object, 'a.b.not.found')); // undefined
Demo: https://jsbin.com/eroqame/3/edit?js,console
1var object = { 2 a: { 3 b: [1,2,3] 4 } 5}; 6 7// modified object 8var res = undefsafe(object, 'a.b.0', 10); 9 10console.log(object); // { a: { b: [10, 2, 3] } } 11console.log(res); // 1 - previous value
As of 1.2.0, undefsafe
supports a *
in the path if you want to search all of the properties (or array elements) for a particular element.
The function will only return a single result, either the 3rd argument validation value, or the first positive match. For example, the following github data:
1const githubData = { 2 commits: [{ 3 modified: [ 4 "one", 5 "two" 6 ] 7 }, /* ... */ ] 8 }; 9 10// first modified file found in the first commit 11console.log(undefsafe(githubData, 'commits.*.modified.0')); 12 13// returns `two` or undefined if not found 14console.log(undefsafe(githubData, 'commits.*.modified.*', 'two'));
The latest stable version of the package.
Stable Version
1
6.3/10
Summary
Prototype Pollution in undefsafe
Affected Versions
< 2.0.3
Patched Versions
2.0.3
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
Found 3/29 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
52 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More