Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

broccoli-output-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

broccoli-output-wrapper - npm Package Compare versions

Comparing version 3.1.1 to 3.2.0

4

dist/index.d.ts
/// <reference types="node" />
import * as fs from 'fs';
import { readFileSync, existsSync, readdirSync, lstatSync, statSync, writeFileSync, appendFileSync, rmdirSync, mkdirSync } from 'fs';
import { readFileSync, existsSync, readdirSync, lstatSync, statSync, writeFileSync, appendFileSync, rmdirSync, mkdirSync, symlinkSync, utimesSync } from 'fs';
declare function outputWrapper(node: any): outputWrapper.FSOutput;

@@ -19,3 +19,5 @@ export = outputWrapper;

symlinkOrCopySync: (srcPath: string, destPath: string) => void;
symlinkSync: typeof symlinkSync;
utimesSync: typeof utimesSync;
}
}

@@ -18,3 +18,5 @@ "use strict";

'unlinkSync',
'symlinkOrCopySync'
'symlinkOrCopySync',
'symlinkSync',
'utimesSync'
]);

@@ -27,9 +29,9 @@ function handleFs(target, propertyName, node, relativePath, ...fsArguments) {

}
if (path_1.isAbsolute(relativePath)) {
throw new Error(`Relative path is expected, path ${relativePath} is an absolute path.`);
let outputPath = relativePath;
if (!path_1.isAbsolute(relativePath)) {
outputPath = path_1.resolve(node.outputPath + '/' + relativePath);
if (!outputPath.includes(node.outputPath)) {
throw new Error(`Traversing above the outputPath is not allowed. Relative path ${relativePath} traverses beyond ${node.outputPath}`);
}
}
let outputPath = path_1.resolve(node.outputPath + '/' + relativePath);
if (!outputPath.includes(node.outputPath)) {
throw new Error(`Traversing above the outputPath is not allowed. Relative path ${relativePath} traverses beyond ${node.outputPath}`);
}
if (WHITELISTEDOPERATION.has(propertyName)) {

@@ -36,0 +38,0 @@ logger.debug(`[operation:${propertyName}] at ${outputPath}`);

{
"name": "broccoli-output-wrapper",
"version": "3.1.1",
"version": "3.2.0",
"description": "Output wrapper is a library to write output file to outputpath.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -17,2 +17,4 @@ # broccoli-output-wrapper

* unlinkSync
* symlinkSync
* utimesSync

@@ -19,0 +21,0 @@ All these operations above are same as File Operations documented in node API [guide](https://nodejs.org/api/fs.html).

import * as fs from 'fs';
import { isAbsolute, resolve } from 'path';
import { readFileSync, existsSync, readdirSync, lstatSync, statSync, writeFileSync, appendFileSync, rmdirSync, mkdirSync } from 'fs';
import { readFileSync, existsSync, readdirSync, lstatSync, statSync, writeFileSync, appendFileSync, rmdirSync, mkdirSync, symlinkSync, utimesSync } from 'fs';
import { removeSync } from 'fs-extra';

@@ -20,3 +20,5 @@ const symlinkOrCopySync = require('symlink-or-copy').sync;

'unlinkSync',
'symlinkOrCopySync'
'symlinkOrCopySync',
'symlinkSync',
'utimesSync'
]);

@@ -30,9 +32,11 @@

}
if (isAbsolute(relativePath)) {
throw new Error(`Relative path is expected, path ${relativePath} is an absolute path.`);
let outputPath = relativePath;
if (!isAbsolute(relativePath)) {
outputPath = resolve(node.outputPath + '/' + relativePath);
if (!outputPath.includes(node.outputPath)) {
throw new Error(`Traversing above the outputPath is not allowed. Relative path ${relativePath} traverses beyond ${node.outputPath}`);
}
}
let outputPath = resolve(node.outputPath + '/' + relativePath);
if (!outputPath.includes(node.outputPath)) {
throw new Error(`Traversing above the outputPath is not allowed. Relative path ${relativePath} traverses beyond ${node.outputPath}`);
}
if(WHITELISTEDOPERATION.has(propertyName)) {

@@ -76,4 +80,6 @@ logger.debug(`[operation:${propertyName}] at ${outputPath}`);

unlinkSync: typeof fs.unlinkSync,
symlinkOrCopySync: (srcPath: string, destPath: string) => void
symlinkOrCopySync: (srcPath: string, destPath: string) => void,
symlinkSync: typeof symlinkSync,
utimesSync: typeof utimesSync
}
}

@@ -24,6 +24,5 @@ const buildOutputWrapper = require('../src');

it(`throws actionable error when absolute path is provided`, function() {
expect(() => output.writeFileSync(`${temp.name}/test.md`, 'test')).to.throw(
`Relative path is expected, path ${temp.name}/test.md is an absolute path.`
);
it(`takes absolute path as input`, function() {
output.writeFileSync('test.md', 'test');
expect(output.existsSync(`${temp.name}/test.md`, 'test')).to.be.true;
});

@@ -39,3 +38,3 @@

expect(() => output.writevSync('test.md', 'test')).to.throw(
/^Operation writevSync is not allowed to use. Allowed operations are readFileSync,existsSync,lstatSync,readdirSync,statSync,writeFileSync,appendFileSync,rmdirSync,mkdirSync,unlinkSync,symlinkOrCopySync$/
/^Operation writevSync is not allowed to use. Allowed operations are readFileSync,existsSync,lstatSync,readdirSync,statSync,writeFileSync,appendFileSync,rmdirSync,mkdirSync,unlinkSync,symlinkOrCopySync,symlinkSync,utimesSync$/
);

@@ -42,0 +41,0 @@ });

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc