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

@netlify/build

Package Overview
Dependencies
Maintainers
12
Versions
1244
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@netlify/build - npm Package Compare versions

Comparing version 0.0.15 to 0.0.16

src/utils/redact.js

2

package.json
{
"name": "@netlify/build",
"version": "0.0.15",
"version": "0.0.16",
"description": "Netlify build module",

@@ -5,0 +5,0 @@ "main": "src/build.js",

@@ -6,11 +6,13 @@ const path = require('path')

const deepLog = require('./utils/deeplog')
const getNetlifyConfig = require('./config')
const resolveNetlifyConfig = require('./config')
const getNelifyConfigFile = require('./utils/hasConfig')
const { toToml } = require('./config')
const { writeFile } = require('./utils/fs')
const { getSecrets, redactStream } = require('./utils/redact')
const netlifyLogs = require('./utils/patch-logs')
const netlifyFunctionsPlugin = require('./plugins/functions')
const netlifyDeployPlugin = require('./plugins/deploy')
const baseDir = process.cwd()
// const pt = require('prepend-transform')
const lifecycle = [

@@ -45,3 +47,3 @@ /* Build initialization steps */

try {
netlifyConfig = await getNetlifyConfig(netlifyConfigPath, cliFlags)
netlifyConfig = await resolveNetlifyConfig(netlifyConfigPath, cliFlags)
} catch (err) {

@@ -214,2 +216,8 @@ console.log('Netlify Config Error')

/* Get user set ENV vars and redact */
const redactedKeys = getSecrets(['SECRET_ENV_VAR', 'MY_API_KEY'])
/* Monkey patch console.log */
const originalConsoleLog = console.log
console.log = netlifyLogs.patch(redactedKeys)
/* Get active build instructions */

@@ -225,3 +233,3 @@ const instructions = fullLifecycle.reduce((acc, n) => {

try {
await execCommand(netlifyConfig.build.command)
await execCommand(netlifyConfig.build.command, redactedKeys)
} catch (err) {

@@ -252,3 +260,3 @@ console.log(chalk.redBright(`Error from netlify config.build.command:`))

// TODO pass in env vars if not available
const stdout = await execCommand(curr)
const stdout = await execCommand(curr, redactedKeys)
return Promise.resolve(data.concat(stdout))

@@ -277,6 +285,2 @@ }, Promise.resolve([]))

const redactedKeys = ['SECRET_ENV_VAR', 'MY_API_KEY']
/* Monkey patch console.log */
console.log = netlifyLogs.patch(redactedKeys)
const buildInstructions = instructions.filter((instruction) => {

@@ -342,2 +346,5 @@ return instruction.hook !== 'onError'

// Reset console.log for CLI
console.log = originalConsoleLog
const IS_NETLIFY = isNetlifyCI()

@@ -365,6 +372,10 @@

async function execCommand(cmd) {
async function execCommand(cmd, secrets) {
console.log(chalk.yellowBright(`Running "${cmd}"`))
const subprocess = execa(`${cmd}`, { shell: true })
subprocess.stdout.pipe(process.stdout)
subprocess.stdout
// Redact ENV vars
.pipe(redactStream(secrets))
// Output to console
.pipe(process.stdout, { end: true })
const { stdout } = await subprocess

@@ -467,1 +478,6 @@ return stdout

}
// Expose Netlify config
module.exports.netlifyConfig = resolveNetlifyConfig
// Expose Netlify config path getter
module.exports.getNelifyConfigFile = getNelifyConfigFile
const chalk = require('chalk')
const util = require('util')
const redactEnv = require('redact-env')
const isPlainObject = require('lodash.isplainobject')
const { redactValues } = require('./redact')
function monkeyPatchLogs(secretKeys) {
const secrets = redactEnv.build(secretKeys)
function monkeyPatchLogs(secrets) {
return {

@@ -66,28 +64,1 @@ apply (target, ctx, args) {

}
// Yoinked from lodash to save dependencies
function isObject(value) {
var type = typeof value
return value != null && (type === 'object' || type === 'function')
}
function redactValues(target, secrets) {
// If it's not an object or string then it's a primitive. Nothing to redact.
if (!isObject(target) && typeof target !== 'string') {
return target
}
// Redact string values
if (typeof target === 'string') {
return redactEnv.redact(target, secrets)
}
// Redact Array values
if (Array.isArray(target)) {
return target.map((val) => redactValues(val, secrets))
} else if (isPlainObject(target)) {
return Object.keys(target).reduce((newObj, key) => {
newObj[key] = redactValues(target[key], secrets)
return newObj
}, {})
}
return target
}
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