Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
parse-passwd
Advanced tools
Package description
The parse-passwd npm package is designed to parse the /etc/passwd file from Unix/Linux systems. This file contains user account information, and parsing it can be useful for system administration, security analysis, and user management tasks. The package provides a simple interface to convert the content of the /etc/passwd file into a JavaScript object for easy manipulation and access.
Parsing /etc/passwd file content
This feature allows you to parse the content of an /etc/passwd file. The code sample demonstrates how to use the parse-passwd package to convert a string representing the content of an /etc/passwd file into an array of user objects. Each object contains information about a user, such as username, password, UID, GID, full name, home directory, and shell.
const parsePasswd = require('parse-passwd');
const passwdContent = 'root:x:0:0:root:/root:/bin/bash\n';
const users = parsePasswd(passwdContent);
console.log(users);
passwd-user is a package that allows you to get user details by their username from the /etc/passwd file. Unlike parse-passwd, which parses the entire file content, passwd-user focuses on retrieving information for a specific user, making it more suitable for targeted queries.
passwd-group is similar to parse-passwd but focuses on parsing the /etc/group file, which contains group information. This package complements parse-passwd by providing group management capabilities, whereas parse-passwd is focused on user account information.
Readme
Parse a passwd file into a list of users.
Install with npm:
$ npm install --save parse-passwd
var parse = require('parse-passwd');
Example
// assuming '/etc/passwd' contains:
// doowb:*:123:123:Brian Woodward:/Users/doowb:/bin/bash
console.log(parse(fs.readFileSync('/etc/passwd', 'utf8')));
//=> [
//=> {
//=> username: 'doowb',
//=> password: '*',
//=> uid: '123',
//=> gid: '123',
//=> gecos: 'Brian Woodward',
//=> homedir: '/Users/doowb',
//=> shell: '/bin/bash'
//=> }
//=> ]
Params
content
{String}: Content of a passwd file to parse.returns
{Array}: Array of user objects parsed from the content.Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Please read the contributing guide for avice on opening issues, pull requests, and coding standards.
(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)
To generate the readme and API documentation with verb:
$ npm install -g verb verb-generate-readme && verb
Install dev dependencies:
$ npm install -d && npm test
Brian Woodward
Copyright © 2016, Brian Woodward. Released under the MIT license.
This file was generated by verb-generate-readme, v0.2.0, on October 19, 2016.
FAQs
Parse a passwd file into a list of users.
The npm package parse-passwd receives a total of 6,416,441 weekly downloads. As such, parse-passwd popularity was classified as popular.
We found that parse-passwd 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.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.