Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Create stats of your source code:
In addition to the default terminal output (see examples below), sloc provides an alternative set of output formatters:
To use sloc as an application install it globally:
sudo npm install -g sloc
If you're going to use it as a Node.js module within your project:
npm install --save sloc
You can also use sloc within your browser application.
Link sloc.js
in your HTML file:
<script src="lib/sloc.js"></script>
sloc [option] <file>|<directory>
Options:
-h, --help output usage information
-V, --version output the version number
-e, --exclude <regex> regular expression to exclude files and folders
-i, --include <regex> regular expression to include files and folders
-f, --format <format> format output: json, csv, cli-table
--format-option [value] add formatter option
-k, --keys <keys> report only numbers of the given keys
-d, --details report stats of each analyzed file
-a, --alias <custom ext>=<standard ext> alias custom ext to act like standard ext (eg. php5=php,less=css)
e.g.:
$ sloc src/
---------- Result ------------
Physical : 1202
Source : 751
Comment : 322
Single-line comment : 299
Block comment : 23
Mixed : 116
Empty : 245
Number of files read : 10
------------------------------
or
$ sloc --details \
--format cli-table \
--keys total,source,comment \
--exclude i18n*.\.coffee \
--format-option no-head src/
┌─────────────────────────────────┬──────────┬────────┬─────────┐
│ src/cli.coffee │ 98 │ 74 │ 7 │
├─────────────────────────────────┼──────────┼────────┼─────────┤
│ src/helpers.coffee │ 26 │ 20 │ 0 │
├─────────────────────────────────┼──────────┼────────┼─────────┤
│ src/sloc.coffee │ 196 │ 142 │ 20 │
├─────────────────────────────────┼──────────┼────────┼─────────┤
│ src/formatters/simple.coffee │ 44 │ 28 │ 7 │
├─────────────────────────────────┼──────────┼────────┼─────────┤
│ src/formatters/csv.coffee │ 25 │ 14 │ 5 │
├─────────────────────────────────┼──────────┼────────┼─────────┤
│ src/formatters/cli-table.coffee │ 22 │ 13 │ 0 │
└─────────────────────────────────┴──────────┴────────┴─────────┘
Or use it in your own node module
var fs = require('fs');
var sloc = require('sloc');
fs.readFile("mySourceFile.coffee", "utf8", function(err, code){
if(err){ console.error(err); }
else{
var stats = sloc(code,"coffee");
for(i in sloc.keys){
var k = sloc.keys[i];
console.log(k + " : " + stats[k]);
}
}
});
var sourceCode = "foo();\n /* bar */\n baz();";
var stats = window.sloc(sourceCode,"javascript");
Fork this repo
add the new formatter into src/formatters/
that exports a
method with three arguments:
add the formatter in src/cli.coffee
open a pull request
Grunt
Gulp
Jenkins
Istanbul
Codemetrics
npm test
npm run prepublish
see CHANGELOG.md
sloc is licensed under the MIT license
FAQs
sloc is a simple tool to count SLOC (source lines of code)
We found that sloc demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.