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.
A simple CLI for making HTML files from EJS templates.
Install:
npm i ejs2html -g
Usage:
ejs2html [options] <config> [dest]
Options:
-h, --help output usage information
-V, --version output the version number
-r, --read <variable_name> Read contents from stdin, if available, and pipe to a given global variable name in the config.
Everything runs off of the config file. It looks something like this.
{
"files": [
{
"dest": "index.html",
"template": "layout",
"locals": {
"title": "Home",
"message": "Welcome to my app."
}
},
{
"dest": "about/index.html",
"template": "layout.ejs",
"locals": {
"title": "About",
"message": "This is the about page."
}
}
],
"globals": {
"app_name": "My App"
}
}
At the root level of the config should be:
Each file object inside of files
should include:
dest
param from the command line.[cli-dest]/[file-dest][.html]
..html
extension is optionalUsing the -r, --read <var_name>
option allows you to receive piped data and set the data to a global variable that can be used in your templates. Without declaring this option, ejs2html
will not do anything with the piped data.
So this will set a new global variable called message
to the contents of hello.txt
:
cat hello.txt | ejs2html config.json --read message
However, the piped data will be ignored in this example:
cat hello.txt | ejs2html config.json
cat hello.txt | ejs2html config.json --read message
"hello.txt"
Hello world!
"layout.js"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><%= title %></title>
</head>
<body>
<h1><%= title %></h1>
<p><%- message %></p>
</body>
</html>
"config.json"
{
"files": [
{
"dest": "index.html",
"template": "layout",
}
],
"globals": {
"title": "My Site",
"message": ""
}
}
The result would be:
"index.html"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My Site</title>
</head>
<body>
<h1>My Site</h1>
<p>Hello world!</p>
</body>
</html>
_"src/ejs/config.json"
{
"files": [
{
"dest": "index.html",
"template": "layout",
"locals": {
"title": "Home",
"message": "Welcome to my app."
}
}
],
"globals": {
"app_name": "My App"
}
}
_"src/ejs/layout.ejs"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><%= app_name %></title>
</head>
<body>
<h1><%= title %></h1>
<p><%= message %></p>
</body>
</html>
Running...
ejs2html _src/ejs/config.json
Yields...
"index.html"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My App</title>
</head>
<body>
<h1>Home</h1>
<p>Welcome to my app.</p>
</body>
</html>
===
_"src/ejs/partials/header.ejs"
<h1><%= title %></h1>
_"src/ejs/partials/body.ejs"
<p><%= message %></p>
_"src/ejs/layout.ejs"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><%= app_name %></title>
</head>
<body>
<%- include('partials/header') %>
<%- include('partials/body') %>
</body>
</html>
Running the following with same config as above would yield the same result as the previous example...
ejs2html _src/ejs/config.json
===
_"src/ejs/config.json"
{
"files": [
{
"dest": "index.html",
"template": "layout",
"locals": {
"title": "Home",
"message": "Welcome to my app."
}
},
{
"dest": "about/index.html",
"template": "layout",
"locals": {
"title": "About",
"message": "This is the about page."
}
}
],
"globals": {
"app_name": "My App"
}
}
_"src/ejs/layout.ejs"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><%= app_name %></title>
</head>
<body>
<h1><%= title %></h1>
<p><%= message %></p>
</body>
</html>
Running...
ejs2html _src/ejs/config.json
Yields...
"index.html"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My App</title>
</head>
<body>
<h1>Home</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum, excepturi.</p>
</body>
</html>
"about/index.html"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My App</title>
</head>
<body>
<h1>About</h1>
<p>This is the about page.</p>
</body>
</html>
npm run sample
Runs some example stuff inside of /example
.
FAQs
A simple CLI for making HTML files from EJS templates.
The npm package ejs2html receives a total of 83 weekly downloads. As such, ejs2html popularity was classified as not popular.
We found that ejs2html 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
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.