
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.
Node.js環境でのウェブサイトテンプレートファイル処理ライブラリ。@c-time/gentlをラップし、jsdomとNodeのファイルシステムを利用してHTMLテンプレートの生成を行います。
WEB制作専用HTMLジェネレータです。
担当者や制作会社が変わっても混乱を招かない、セキュアでWEB制作現場に寄り添ったシンプルなHTMLジェネレータです。
このライブラリは@c-time/gentl - WEB制作専用HTMLジェネレータ - をベースとしており、以下の特徴を継承しています:
<template>タグによる非破壊的な展開でDOM構造を保護。生成後のHTMLも再びテンプレートとして再利用可能Node.js環境でのウェブサイトテンプレートファイル処理ライブラリです。@c-time/gentlをラップし、jsdomとNodeのファイルシステムを利用してHTMLを生成します。
npm install gentl-node
import { GentlNode, type IGentlNode } from 'gentl-node';
const gentlNode: IGentlNode = new GentlNode('./output-root', {
includeDirectory: './includes' // 絶対パスまたはカレントディレクトリからの相対パス
});
// 単一HTMLファイルを生成
await gentlNode.generateFile(
'./templates/page.html', // テンプレートファイル(カレントディレクトリから)
'./data/page-data.json', // データファイル(カレントディレクトリから)
'page.html' // 出力ファイル(出力ルートディレクトリから)
);
// データディレクトリ内のすべてのJSONファイルから複数HTMLを生成
const generatedFiles = await gentlNode.generateFiles(
'./templates/product.html', // テンプレートファイル(カレントディレクトリから)
'./data/products', // JSONファイルが格納されたディレクトリ(カレントディレクトリから)
'products', // 出力ディレクトリ(出力ルートディレクトリから)
'product-{data.id}.html' // ファイル名規則
);
console.log('Generated files:', generatedFiles);
// => ['products/product-001.html', 'products/product-002.html', ...]
interface IGentlNode {
setBaseData(baseDataPath: string): Promise<void>;
generateFile(templatePath: string, dataPath: string, outputPath: string): Promise<void>;
generateFiles(templatePath: string, dataPath: string, outputDir: string, namingRule: string): Promise<string[]>;
}
class GentlNode implements IGentlNode {
constructor(outputRootDirectory: string, options?: GentlNodeOptions)
}
string - 出力ファイル専用のルートディレクトリ(必須)GentlNodeOptions - 設定オプション(省略可能)type GentlNodeOptions = Partial<GentlJOptions> & {
includeDirectory?: string; // includeファイルのディレクトリ
logger?: Logger; // カスタムロガー
includeNotFoundHandler?: IncludeNotFoundHandler; // include未発見時のハンドラー
}
単一のHTMLファイルを生成します。
generateFile(
templatePath: string, // 絶対パスまたは現在の作業ディレクトリからの相対パス
dataPath: string, // 絶対パスまたは現在の作業ディレクトリからの相対パス
outputPath: string // 出力ルートディレクトリからの相対パス
): Promise<void>
複数のHTMLファイルを一括生成します。
generateFiles(
templatePath: string, // 絶対パスまたは現在の作業ディレクトリからの相対パス
dataPath: string, // 絶対パスまたは現在の作業ディレクトリからの相対パス
outputDir: string, // 出力ルートディレクトリからの相対パス
namingRule: string
): Promise<string[]>
namingRule で使用可能な変数:
{index} - 0から始まるインデックス番号{fileName} - JSONファイル名(拡張子なし){data.property} - JSONデータのプロパティ値(ネスト対応)// ベースデータを設定(全てのファイル生成でマージされる)
setBaseData(baseDataPath: string): Promise<void> // 絶対パスまたは現在の作業ディレクトリからの相対パス
import { GentlNode, type Logger } from 'gentl-node';
const customLogger: Logger = (entry) => {
// カスタムログ処理
console.log(`[${entry.level}] ${entry.message}`);
if (entry.context?.error) {
console.error(entry.context.error);
}
};
const gentlNode = new GentlNode('./project', {
logger: customLogger
});
全てのファイル生成で共通して使用されるベースデータを設定できます。
import { GentlNode, type IGentlNode } from 'gentl-node';
const gentlNode: IGentlNode = new GentlNode('./project');
// ベースデータを設定
await gentlNode.setBaseData('data/base.json');
// 以降のgenerateFile/generateFilesでベースデータが自動的にマージされる
await gentlNode.generateFile('templates/page.html', 'data/page.json', 'output/page.html');
データマージの仕組み:
{...fileData, ...baseData}includeファイルが見つからない場合のカスタム処理を定義できます。
const gentlNode = new GentlNode('./project', {
includeDirectory: 'includes',
includeNotFoundHandler: async (key: string, baseData?: object) => {
// カスタム処理(例:デフォルトコンテンツの提供)
console.warn(`Include file not found: ${key}`);
return `<div class="missing-include">Content for "${key}" is not available</div>`;
}
});
未設定の場合、includeファイルが見つからないとエラーがスローされます。
project/
├── templates/
│ └── page.html
├── includes/
│ ├── header.html
│ ├── footer.html
│ └── components/
│ └── button.html
└── data/
└── page.json
テンプレート内でのinclude使用例:
<!-- templates/page.html -->
<html>
<head>
<title>My Page</title>
</head>
<body>
<template data-gen-scope="" data-gen-include="header.html"></template>
<main>
<template data-gen-scope="">
<h1 data-gen-text="title">Page Title</h1>
</template>
<template data-gen-scope="" data-gen-include="components/button.html"></template>
</main>
<template data-gen-scope="" data-gen-include="footer.html"></template>
</body>
</html>
../ などによる出力ルートディレクトリ外へのアクセスを防止my-project/
├── templates/ # テンプレートファイル(任意の場所)
│ ├── index.html
│ └── product.html
├── includes/ # includeファイル(任意の場所)
│ ├── nav.html
│ ├── footer.html
│ └── components/
│ ├── card.html
│ └── button.html
├── data/ # データファイル(任意の場所)
│ ├── base.json # ベースデータ(全ファイル共通)
│ ├── index.json
│ └── products/
│ ├── product-1.json
│ ├── product-2.json
│ └── product-3.json
└── dist/ # 出力専用ディレクトリ(出力ルートディレクトリ)
├── index.html
└── products/
├── product-1.html
├── product-2.html
└── product-3.html
使用例:
const gentlNode = new GentlNode('./dist', {
includeDirectory: './includes'
});
await gentlNode.setBaseData('./data/base.json');
await gentlNode.generateFile('./templates/index.html', './data/index.json', 'index.html');
data/base.json の例:
{
"siteName": "My Website",
"version": "1.0.0",
"author": "John Doe",
"meta": {
"description": "Welcome to my website",
"keywords": ["web", "site", "example"]
}
}
data/products/product-1.json の例:
{
"title": "Product 1",
"price": "$29.99",
"description": "Amazing product description"
}
マージ後のデータ(product-1.html生成時):
{
"title": "Product 1",
"price": "$29.99",
"description": "Amazing product description",
"siteName": "My Website",
"version": "1.0.0",
"author": "John Doe",
"meta": {
"description": "Welcome to my website",
"keywords": ["web", "site", "example"]
}
}
try {
await gentlNode.generateFile('template.html', 'data.json', 'output.html');
} catch (error) {
console.error('Generation failed:', error.message);
}
よくあるエラー:
このプロジェクトのライセンスについては、LICENSE ファイルを参照してください。
バグレポートや機能リクエストは、GitHubのIssuesページでお受けしています。
git clone https://github.com/c-time/gentl-node.git
cd gentl-node
npm install
npm run build # TypeScriptビルド
npm run dev # 開発モード(ファイル監視)
npm test # テスト実行
npm run test:watch # テスト監視モード
npm run test:coverage # カバレッジ付きテスト
npm run clean # ビルドファイル削除
npm run prepublishOnly # ビルド+テスト
npm publish # npm公開
FAQs
Node.js環境でのウェブサイトテンプレートファイル処理ライブラリ。@c-time/gentlをラップし、jsdomとNodeのファイルシステムを利用してHTMLテンプレートの生成を行います。
We found that gentl-node 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.

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.