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

regedit

Package Overview
Dependencies
Maintainers
3
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

regedit - npm Package Compare versions

Comparing version 2.2.6 to 2.2.7

.eslintignore

2

errors.js

@@ -0,1 +1,3 @@

/* eslint-disable max-len */
var errors = {}

@@ -2,0 +4,0 @@

357

index.js

@@ -39,100 +39,102 @@ var util = require('util')

if (architecture === undefined) {
callback = undefined
architecture = OS_ARCH_AGNOSTIC
} else if (typeof architecture === 'function') {
callback = architecture
architecture = OS_ARCH_AGNOSTIC
}
if (architecture === undefined) {
callback = undefined
architecture = OS_ARCH_AGNOSTIC
}
else if (typeof architecture === 'function') {
callback = architecture
architecture = OS_ARCH_AGNOSTIC
}
if (typeof keys === 'string') {
keys = [keys]
}
if (typeof keys === 'string') {
keys = [keys]
}
if (typeof callback === 'function') {
execute(toCommandArgs('regList.wsf', architecture, keys), callback)
} else {
var outputStream = through2.obj(helper.vbsOutputTransform)
if (typeof callback === 'function') {
execute(toCommandArgs('regList.wsf', architecture, keys), callback)
}
else {
var outputStream = through2.obj(helper.vbsOutputTransform)
cscript.init(function (err) {
if (err) {
return outputStream.emit('error', err)
}
cscript.init(function (err) {
if (err) {
return outputStream.emit('error', err)
}
var args = baseCommand('regListStream.wsf', architecture)
var args = baseCommand('regListStream.wsf', architecture)
var child = execFile(cscript.path(), args, { encoding: 'utf8' }, function(err) {
if (err) {
outputStream.emit('error', err)
}
})
var child = execFile(cscript.path(), args, {encoding: 'utf8'}, function(err) {
if (err) {
outputStream.emit('error', err)
}
})
child.stderr.pipe(process.stderr)
child.stderr.pipe(process.stderr)
var slicer = new StreamSlicer({ sliceBy: helper.WIN_EOL })
var slicer = new StreamSlicer({sliceBy: helper.WIN_EOL})
child.stdout.pipe(slicer).pipe(outputStream)
child.stdout.pipe(slicer).pipe(outputStream)
helper.writeArrayToStream(keys, child.stdin)
})
helper.writeArrayToStream(keys, child.stdin)
})
return outputStream
}
return outputStream
}
}
module.exports.createKey = function (keys, architecture, callback) {
if (typeof architecture === 'function') {
callback = architecture
architecture = OS_ARCH_AGNOSTIC
}
if (typeof architecture === 'function') {
callback = architecture
architecture = OS_ARCH_AGNOSTIC
}
if (typeof keys === 'string') {
keys = [keys]
}
if (typeof keys === 'string') {
keys = [keys]
}
var args = baseCommand('regCreateKey.wsf', architecture)
var args = baseCommand('regCreateKey.wsf', architecture)
spawnEx(args, keys, callback)
spawnEx(args, keys, callback)
}
module.exports.deleteKey = function (keys, architecture, callback) {
if (typeof architecture === 'function') {
callback = architecture
architecture = OS_ARCH_AGNOSTIC
}
if (typeof architecture === 'function') {
callback = architecture
architecture = OS_ARCH_AGNOSTIC
}
if (typeof keys === 'string') {
keys = [keys]
}
if (typeof keys === 'string') {
keys = [keys]
}
var args = baseCommand('regDeleteKey.wsf', architecture)
var args = baseCommand('regDeleteKey.wsf', architecture)
spawnEx(args, keys, callback)
spawnEx(args, keys, callback)
}
module.exports.putValue = function(map, architecture, callback) {
if (typeof architecture === 'function') {
callback = architecture
architecture = OS_ARCH_AGNOSTIC
}
if (typeof architecture === 'function') {
callback = architecture
architecture = OS_ARCH_AGNOSTIC
}
var args = baseCommand('regPutValue.wsf', architecture)
var args = baseCommand('regPutValue.wsf', architecture)
var values = []
var values = []
for (var key in map) {
var keyValues = map[key]
for (var key in map) {
var keyValues = map[key]
for (var valueName in keyValues) {
var entry = keyValues[valueName]
for (var valueName in keyValues) {
var entry = keyValues[valueName]
// helper writes the array to the stream in reversed order
values.push(entry.type)
values.push(renderValueByType(entry.value, entry.type))
values.push(valueName)
values.push(key)
}
}
values.push(entry.type)
values.push(renderValueByType(entry.value, entry.type))
values.push(valueName)
values.push(key)
}
}
spawnEx(args, values, callback)
spawnEx(args, values, callback)
}

@@ -143,47 +145,47 @@

module.exports.arch.list = function(keys, callback) {
return module.exports.list(keys, OS_ARCH_SPECIFIC, callback)
return module.exports.list(keys, OS_ARCH_SPECIFIC, callback)
}
module.exports.arch.list32 = function (keys, callback) {
return module.exports.list(keys, OS_ARCH_32BIT, callback)
return module.exports.list(keys, OS_ARCH_32BIT, callback)
}
module.exports.arch.list64 = function (keys, callback) {
return module.exports.list(keys, OS_ARCH_64BIT, callback)
return module.exports.list(keys, OS_ARCH_64BIT, callback)
}
module.exports.arch.createKey = function (keys, callback) {
return module.exports.createKey(keys, OS_ARCH_SPECIFIC, callback)
return module.exports.createKey(keys, OS_ARCH_SPECIFIC, callback)
}
module.exports.arch.createKey32 = function (keys, callback) {
return module.exports.createKey(keys, OS_ARCH_32BIT, callback)
return module.exports.createKey(keys, OS_ARCH_32BIT, callback)
}
module.exports.arch.createKey64 = function (keys, callback) {
return module.exports.createKey(keys, OS_ARCH_64BIT, callback)
return module.exports.createKey(keys, OS_ARCH_64BIT, callback)
}
module.exports.arch.deleteKey = function (keys, callback) {
return module.exports.deleteKey(keys, OS_ARCH_SPECIFIC, callback)
return module.exports.deleteKey(keys, OS_ARCH_SPECIFIC, callback)
}
module.exports.arch.deleteKey32 = function (keys, callback) {
return module.exports.deleteKey(keys, OS_ARCH_32BIT, callback)
return module.exports.deleteKey(keys, OS_ARCH_32BIT, callback)
}
module.exports.arch.deleteKey64 = function (keys, callback) {
return module.exports.deleteKey(keys, OS_ARCH_64BIT, callback)
return module.exports.deleteKey(keys, OS_ARCH_64BIT, callback)
}
module.exports.arch.putValue = function (keys, callback) {
return module.exports.putValue(keys, OS_ARCH_SPECIFIC, callback)
return module.exports.putValue(keys, OS_ARCH_SPECIFIC, callback)
}
module.exports.arch.putValue32 = function (keys, callback) {
return module.exports.putValue(keys, OS_ARCH_32BIT, callback)
return module.exports.putValue(keys, OS_ARCH_32BIT, callback)
}
module.exports.arch.putValue64 = function (keys, callback) {
return module.exports.putValue(keys, OS_ARCH_64BIT, callback)
return module.exports.putValue(keys, OS_ARCH_64BIT, callback)
}

@@ -193,90 +195,101 @@

if (typeof callback !== 'function') {
throw new Error('missing callback')
}
if (typeof callback !== 'function') {
throw new Error('missing callback')
}
debug(args)
debug(args)
cscript.init(function (err) {
if (err) return callback(err)
cscript.init(function (err) {
if (err) {
return callback(err)
}
childProcess.execFile(cscript.path(), args, function (err, stdout, stderr) {
childProcess.execFile(cscript.path(), args, function (err, stdout, stderr) {
if (err) {
if (stdout) {
console.log(stdout)
}
if (err) {
if (stdout) {
console.log(stdout)
}
if (stderr) {
console.error(stderr)
}
if (stderr) {
console.error(stderr)
}
if (err.code in errors) {
return callback(errors[err.code])
} else {
return callback(err)
}
}
if (err.code in errors) {
return callback(errors[err.code])
}
return callback(err)
}
// in case we have stuff in stderr but no real error
if (stderr) return callback(new Error(stderr))
if (!stdout) return callback()
if (stderr) {
return callback(new Error(stderr))
}
if (!stdout) {
return callback()
}
debug(stdout)
debug(stdout)
var result, err
try {
result = JSON.parse(stdout)
} catch (e) {
e.stdout = stdout
err = e
}
var result
err = null
callback(err, result)
})
})
try {
result = JSON.parse(stdout)
}
catch (e) {
e.stdout = stdout
err = e
}
callback(err, result)
})
})
}
function spawnEx(args, keys, callback) {
cscript.init(function (err) {
if (err) return callback(err)
cscript.init(function (err) {
if (err) {
return callback(err)
}
debug(args)
debug(args)
var child = execFile(cscript.path(), args, { encoding: 'utf8' })
var child = execFile(cscript.path(), args, {encoding: 'utf8'})
handleErrorsAndClose(child, callback)
handleErrorsAndClose(child, callback)
helper.writeArrayToStream(keys, child.stdin)
})
helper.writeArrayToStream(keys, child.stdin)
})
}
function handleErrorsAndClose (child, callback) {
var error
child.once('error', function(e) {
debug('process error %s', e)
error = e
})
var error
child.once('error', function(e) {
debug('process error %s', e)
error = e
})
child.once('close', function (code) {
debug('process exit with code %d', code)
child.once('close', function (code) {
debug('process exit with code %d', code)
if (error) {
if (error.code in errors) {
return callback(errors[err.code])
} else {
return callback(error)
}
}
if (error) {
if (error.code in errors) {
return callback(errors[error.code])
}
return callback(error)
}
if (code !== 0) {
if (code in errors) {
return callback(errors[code])
} else {
return callback(new Error('vbscript process reported unknown error code ' + code))
}
}
if (code !== 0) {
if (code in errors) {
return callback(errors[code])
}
return callback(new Error('vbscript process reported unknown error code ' + code))
}
callback()
})
callback()
})
}

@@ -286,26 +299,26 @@

function renderValueByType(value, type) {
type = type.toUpperCase()
type = type.toUpperCase()
switch (type) {
case 'REG_BINARY':
if (!util.isArray(value)) {
throw new Error('invalid value type ' + typeof (value) + ' for registry type REG_BINARY, please use an array of numbers')
}
return value.join(',')
switch (type) {
case 'REG_BINARY':
if (!util.isArray(value)) {
throw new Error('invalid value type ' + typeof (value) + ' for registry type REG_BINARY, please use an array of numbers')
}
return value.join(',')
case 'REG_MULTI_SZ':
if (!util.isArray(value)) {
throw new Error('invalid value type ' + typeof (value) + ' for registry type REG_BINARY, please use an array of strings')
}
return value.join(',')
case 'REG_MULTI_SZ':
if (!util.isArray(value)) {
throw new Error('invalid value type ' + typeof (value) + ' for registry type REG_BINARY, please use an array of strings')
}
return value.join(',')
case 'REG_SZ':
if (value === '') {
return '\0'
}
return value
case 'REG_SZ':
if (value === '') {
return '\0'
}
return value
default:
return value
}
default:
return value
}
}

@@ -315,12 +328,14 @@

function toCommandArgs(cmd, arch, keys) {
var result = baseCommand(cmd, arch)
if (typeof keys === 'string') {
result.push(keys)
} else if (util.isArray(keys)) {
result = result.concat(keys)
} else {
debug('creating command without using keys %s', keys ? keys : '')
}
var result = baseCommand(cmd, arch)
if (typeof keys === 'string') {
result.push(keys)
}
else if (util.isArray(keys)) {
result = result.concat(keys)
}
else {
debug('creating command without using keys %s', keys ? keys : '')
}
return result
return result
}

@@ -330,3 +345,3 @@

function baseCommand(cmd, arch) {
return ['//Nologo', path.join(__dirname, 'vbs', cmd), arch]
return ['//Nologo', path.join(__dirname, 'vbs', cmd), arch]
}

@@ -0,1 +1,3 @@

/* eslint-disable global-require */
var ifAsync

@@ -11,7 +13,7 @@ var fs

function resetDependencies() {
init = false
ifAsync = require('if-async')
fs = require('fs')
execFile = require('../lib/execFile.js')({ bufferStdout: true, bufferStderr: true })
debug = require('debug')('regedit:cscript')
init = false
ifAsync = require('if-async')
fs = require('fs')
execFile = require('../lib/execFile.js')({bufferStdout: true, bufferStderr: true})
debug = require('debug')('regedit:cscript')
}

@@ -35,16 +37,18 @@

// this sucks...
if (init === false) throw new Error('must initialize first')
debug(cscript)
return cscript
if (init === false) {
throw new Error('must initialize first')
}
debug(cscript)
return cscript
}
module.exports.init = function (callback) {
debug('init()')
debug('init()')
if (init) {
debug('already initialized')
return setImmediate(callback)
}
if (init) {
debug('already initialized')
return setImmediate(callback)
}
var functor =
var functor =
ifAsync(spawnCScriptSucceeded)

@@ -54,19 +58,19 @@ .or(whereCScriptSucceeded)

.then(function (cb) {
init = true
cb()
})
init = true
cb()
})
.else(callbackWithError)
functor(function (err) {
if (err) {
return callback(err)
}
callback()
})
functor(function (err) {
if (err) {
return callback(err)
}
callback()
})
}
module.exports._mock = function(_fs, _execFile, _init) {
fs = _fs
execFile = _execFile
init = _init
fs = _fs
execFile = _execFile
init = _init
}

@@ -77,71 +81,77 @@

function spawnCScriptSucceeded (callback) {
debug('spawnCScriptSucceeded()')
debug('spawnCScriptSucceeded()')
execFile('cscript.exe', function (err, stdout, stderr) {
execFile('cscript.exe', function (err, stdout, stderr) {
if (err) {
if (err) {
// where command not found on this system
if (err.code === 'ENOENT') {
return callback(null, false)
} else {
return callback(err)
}
}
if (err.code === 'ENOENT') {
return callback(null, false)
}
return callback(err)
}
cscript = 'cscript.exe'
callback(null, stdout.indexOf(CSCRIPT_EXPECTED_OUTPUT) > -1)
})
cscript = 'cscript.exe'
callback(null, stdout.indexOf(CSCRIPT_EXPECTED_OUTPUT) > -1)
})
}
function whereCScriptSucceeded (callback) {
debug('whereCScriptSucceeded()')
debug('whereCScriptSucceeded()')
execFile('where cscript.exe', function (err, stdout, stderr) {
execFile('where cscript.exe', function (err, stdout, stderr) {
if (err) {
if (err) {
// where command not found on this system
if (err.code === 'ENOENT') {
return callback(null, false)
} else {
return callback(err)
}
}
if (err.code === 'ENOENT') {
return callback(null, false)
}
return callback(err)
}
if (typeof stdout !== 'string') return callback(null, false)
if (stdout.indexOf(CSCRIPT_NOT_FOUND) > -1) return callback(null, false)
if (typeof stdout !== 'string') {
return callback(null, false)
}
if (stdout.indexOf(CSCRIPT_NOT_FOUND) > -1) {
return callback(null, false)
}
cscript = stdout.trim()
callback(null, true)
})
cscript = stdout.trim()
callback(null, true)
})
}
function fsStatCScriptSucceeded(callback) {
debug('fsStatCScriptSucceeded()')
debug('fsStatCScriptSucceeded()')
fs.stat('c:\\windows\\system32\\cscript.exe', function(err, stat) {
if (err) {
if (err.code === 'ENOENT') {
return callback(null, false)
} else {
return callback(err)
}
}
fs.stat('c:\\windows\\system32\\cscript.exe', function(err, stat) {
if (err) {
if (err.code === 'ENOENT') {
return callback(null, false)
}
return callback(err)
}
cscript = 'c:\\windows\\system32\\cscript.exe'
callback(null, true)
})
cscript = 'c:\\windows\\system32\\cscript.exe'
callback(null, true)
})
}
function callbackWithError(cb) {
cb(new Error('cscript not found'))
cb(new Error('cscript not found'))
}
function once (cb) {
var fired = false
return function () {
if (fired) return cb()
fired = true
var fired = false
return function () {
if (fired) {
return cb()
}
fired = true
cb.apply(null, arguments)
}
}
cb.apply(null, arguments)
}
}
var childProcess = require('child_process')
module.exports = function(options) {
options = options || {}
options = options || {}
return function execFile () {
return function execFile () {
var child = childProcess.execFile.apply(childProcess, arguments)
var child = childProcess.execFile.apply(childProcess, arguments)
if (!options.bufferStdout) {
child.stdout.removeAllListeners('data')
}
if (!options.bufferStdout) {
child.stdout.removeAllListeners('data')
}
if (!options.bufferStderr) {
child.stderr.removeAllListeners('data')
}
if (!options.bufferStderr) {
child.stderr.removeAllListeners('data')
}
return child
}
return child
}
}

@@ -8,3 +8,3 @@ var debug = require('debug')('regedit')

module.exports.encode = function(str) {
return escape(str) + WIN_EOL
return escape(str) + WIN_EOL
}

@@ -17,43 +17,45 @@

var encoding = 'utf8'
var member = arr.pop()
var encoding = 'utf8'
var member = arr.pop()
function write(m) {
if (m !== undefined) {
var b = module.exports.encode(m)
debug(b)
return stream.write(b)
}
function write(m) {
if (m !== undefined) {
var b = module.exports.encode(m)
debug(b)
return stream.write(b)
}
return false
}
return false
}
while (write(member)) {
member = arr.pop()
}
while (write(member)) {
member = arr.pop()
}
if (arr.length === 0) {
stream.write(WIN_EOL, optionalCallback)
return
}
if (arr.length === 0) {
stream.write(WIN_EOL, optionalCallback)
return
}
stream.once('drain', function () {
module.exports.writeArrayToStream(arr, stream, optionalCallback)
})
stream.once('drain', function () {
module.exports.writeArrayToStream(arr, stream, optionalCallback)
})
}
module.exports.vbsOutputTransform = function (chunk, enc, callback) {
try {
if (enc === 'buffer') {
chunk = chunk.toString()
} else {
chunk = chunk.toString(enc)
}
try {
if (enc === 'buffer') {
chunk = chunk.toString()
}
else {
chunk = chunk.toString(enc)
}
this.push(JSON.parse(chunk))
} catch (e) {
return callback(e)
}
this.push(JSON.parse(chunk))
}
catch (e) {
return callback(e)
}
return callback()
return callback()
}
{
"name": "regedit",
"version": "2.2.6",
"version": "2.2.7",
"description": "Read, Write, List and do all sorts of funky stuff to the windows registry using node.js and windows script host",

@@ -11,3 +11,7 @@ "keywords": [

"scripts": {
"test": "mocha -R spec"
"lint": "eslint . --fix",
"lint:src": "eslint . --fix --ignore-pattern test/",
"lint:test": "eslint test --fix",
"test": "mocha -R spec",
"prepush": "npm run lint"
},

@@ -34,2 +38,4 @@ "dependencies": {

"devDependencies": {
"eslint": "^3.19.0",
"husky": "^0.13.4",
"mocha": "^2.3.4",

@@ -36,0 +42,0 @@ "should": "^4.4.2"

@@ -5,49 +5,55 @@ var should = require('should')

describe.skip('benchmark test', function (done) {
this.timeout(40000)
this.timeout(40000)
var testSize = 10000
var staticBaseKey = 'HKCU\\software\\ironSource\\test\\bench\\'
var testSize = 10000
var staticBaseKey = 'HKCU\\software\\ironSource\\test\\bench\\'
var baseKey, keys
var baseKey, keys
it('create', function (done) {
it('create', function (done) {
console.time('start create')
index.createKey(keys, function(err, result) {
if (err) return done(err)
console.timeEnd('start create')
done()
})
})
console.time('start create')
index.createKey(keys, function(err, result) {
if (err) {
return done(err)
}
console.timeEnd('start create')
done()
})
})
it('test', function (done) {
index.createKey(keys, function(err, result) {
if (err) return done(err)
console.timeEnd('start create')
index.list(baseKey, function (err, result) {
if (err) return done(err)
console.time('start create')
done()
})
})
})
it('test', function (done) {
index.createKey(keys, function(err, result) {
if (err) {
return done(err)
}
console.timeEnd('start create')
index.list(baseKey, function (err, result) {
if (err) {
return done(err)
}
console.time('start create')
done()
})
})
})
beforeEach(function (done) {
baseKey = staticBaseKey + Date.now()
beforeEach(function (done) {
baseKey = staticBaseKey + Date.now()
// clear remains of previous tests
index.deleteKey(staticBaseKey, function (err) {
if (err) {
console.log(err)
console.log('this is of no consequence, probably.')
}
index.deleteKey(staticBaseKey, function (err) {
if (err) {
console.log(err)
console.log('this is of no consequence, probably.')
}
// create N keys for the test
keys = []
keys = []
for (var i = 0; i < testSize; i++) {
keys.push(baseKey + '\\' + i)
}
})
})
for (var i = 0; i < testSize; i++) {
keys.push(baseKey + '\\' + i)
}
})
})
})

@@ -0,1 +1,3 @@

/* eslint-disable consistent-this */
var should = require('should')

@@ -5,111 +7,121 @@ var cscript = require('../lib/cscript.js')

describe('cscript', function () {
var mockFs, mockExecFile
var mockFs, mockExecFile
it('must be initialized', function () {
(function () {
cscript.path()
}).should.throw('must initialize first')
})
it('must be initialized', function () {
(function () {
cscript.path()
}).should.throw('must initialize first')
})
it('if cscript.exe is successfully spawned then no more checks are conducted', function (done) {
mockExecFile['cscript.exe'].calls.should.eql(0)
mockExecFile['cscript.exe'].stdout = cscript.CSCRIPT_EXPECTED_OUTPUT
it('if cscript.exe is successfully spawned then no more checks are conducted', function (done) {
mockExecFile['cscript.exe'].calls.should.eql(0)
mockExecFile['cscript.exe'].stdout = cscript.CSCRIPT_EXPECTED_OUTPUT
cscript.init(function (err) {
if (err) return done(err)
cscript.init(function (err) {
if (err) {
return done(err)
}
mockExecFile['cscript.exe'].calls.should.eql(1)
mockExecFile['cscript.exe'].args[0].should.eql('cscript.exe')
done()
})
})
mockExecFile['cscript.exe'].calls.should.eql(1)
mockExecFile['cscript.exe'].args[0].should.eql('cscript.exe')
done()
})
})
it('initializes only once', function (done) {
it('initializes only once', function (done) {
mockExecFile['cscript.exe'].calls.should.eql(0)
mockExecFile['cscript.exe'].stdout = cscript.CSCRIPT_EXPECTED_OUTPUT
mockExecFile['cscript.exe'].calls.should.eql(0)
mockExecFile['cscript.exe'].stdout = cscript.CSCRIPT_EXPECTED_OUTPUT
cscript.init(function (err) {
if (err) return done(err)
cscript.init(function (err) {
if (err) {
return done(err)
}
mockExecFile['cscript.exe'].calls.should.eql(1)
mockExecFile['cscript.exe'].calls.should.eql(1)
cscript.init(function (err) {
if (err) return done(err)
cscript.init(function (err) {
if (err) {
return done(err)
}
mockExecFile['cscript.exe'].calls.should.eql(1)
mockExecFile['where cscript.exe'].calls.should.eql(0)
done()
})
})
})
mockExecFile['cscript.exe'].calls.should.eql(1)
mockExecFile['where cscript.exe'].calls.should.eql(0)
done()
})
})
})
it('if cscript.exe fails to execute, try to run "where cscript.exe"', function (done) {
mockExecFile['cscript.exe'].calls.should.eql(0)
mockExecFile['where cscript.exe'].calls.should.eql(0)
it('if cscript.exe fails to execute, try to run "where cscript.exe"', function (done) {
mockExecFile['cscript.exe'].calls.should.eql(0)
mockExecFile['where cscript.exe'].calls.should.eql(0)
mockExecFile['cscript.exe'].err = new Error()
mockExecFile['cscript.exe'].err.code = 'ENOENT'
mockExecFile['where cscript.exe'].stdout = '123'
mockExecFile['cscript.exe'].err = new Error()
mockExecFile['cscript.exe'].err.code = 'ENOENT'
mockExecFile['where cscript.exe'].stdout = '123'
cscript.init(function (err) {
if (err) return done(err)
cscript.init(function (err) {
if (err) {
return done(err)
}
mockExecFile['cscript.exe'].calls.should.eql(1)
mockExecFile['where cscript.exe'].calls.should.eql(1)
mockExecFile['cscript.exe'].calls.should.eql(1)
mockExecFile['where cscript.exe'].calls.should.eql(1)
cscript.path().should.eql('123')
done()
})
})
cscript.path().should.eql('123')
done()
})
})
beforeEach(function () {
mockFs = {
err: null,
calls: 0,
stat: function (name, cb) {
this.calls++
var self = this
setImmediate(function () {
cb(self.err, {})
})
}
}
beforeEach(function () {
mockFs = {
err: null,
calls: 0,
stat: function (name, cb) {
this.calls++
var self = this
setImmediate(function () {
cb(self.err, {})
})
},
}
mockExecFile = function(command, args, options, callback) {
if (!mockExecFile[command]) throw new Error('unexpected command ' + command)
mockExecFile = function(command, args, options, callback) {
if (!mockExecFile[command]) {
throw new Error('unexpected command ' + command)
}
mockExecFile[command].args = arguments
mockExecFile[command].calls++
mockExecFile[command].args = arguments
mockExecFile[command].calls++
if (typeof args === 'function') {
callback = args
args = undefined
options = undefined
}
if (typeof args === 'function') {
callback = args
args = undefined
options = undefined
}
if (typeof options === 'function') {
callback = options
args = undefined
options = undefined
}
if (typeof options === 'function') {
callback = options
args = undefined
options = undefined
}
if (typeof callback !== 'function') {
throw new Error('missing callback')
}
if (typeof callback !== 'function') {
throw new Error('missing callback')
}
setImmediate(function () {
callback(mockExecFile[command].err, mockExecFile[command].stdout, mockExecFile[command].stderr)
})
}
setImmediate(function () {
callback(mockExecFile[command].err, mockExecFile[command].stdout, mockExecFile[command].stderr)
})
}
mockExecFile['cscript.exe'] = { calls: 0, stdout: '', stderr: '', err: null }
mockExecFile['where cscript.exe'] = { calls: 0, stdout: '', stderr: '', err: null }
mockExecFile['cscript.exe'] = {calls: 0, stdout: '', stderr: '', err: null}
mockExecFile['where cscript.exe'] = {calls: 0, stdout: '', stderr: '', err: null}
cscript._mock(mockFs, mockExecFile, false)
})
cscript._mock(mockFs, mockExecFile, false)
})
afterEach(function () {
cscript._mockReset()
})
})
afterEach(function () {
cscript._mockReset()
})
})

@@ -0,1 +1,3 @@

/* eslint-disable max-len, no-unused-expressions */
var should = require('should')

@@ -10,54 +12,54 @@ var execFile = require('../lib/execFile.js')

it('removes all the listeners from stdout/stderr to avoid buffering output, but enjoys all the good cleanup code node.js has to offer', function(done) {
it('removes all the listeners from stdout/stderr to avoid buffering output, but enjoys all the good cleanup code node.js has to offer', function(done) {
var child = execFile()('node', [testScript], function(err, stdout, stderr) {
err.should.be.an.Error
stdout.should.eql('')
stderr.should.eql('')
done()
})
})
var child = execFile()('node', [testScript], function(err, stdout, stderr) {
err.should.be.an.Error
stdout.should.eql('')
stderr.should.eql('')
done()
})
})
it('does not buffer stdout', function(done) {
it('does not buffer stdout', function(done) {
var opts = {
bufferStderr: true
}
var opts = {
bufferStderr: true,
}
var child = execFile(opts)('node', [testScript], function(err, stdout, stderr) {
err.should.be.an.Error
stdout.should.eql('')
stderr.should.containEql('throw new Error(\'error\')')
done()
})
})
var child = execFile(opts)('node', [testScript], function(err, stdout, stderr) {
err.should.be.an.Error
stdout.should.eql('')
stderr.should.containEql('throw new Error(\'error\')')
done()
})
})
it('does not buffer stderr', function(done) {
it('does not buffer stderr', function(done) {
var opts = {
bufferStdout: true
}
var opts = {
bufferStdout: true,
}
var child = execFile(opts)('node', [testScript], function(err, stdout, stderr) {
err.should.be.an.Error
stdout.should.eql('123\n')
stderr.should.eql('')
done()
})
})
var child = execFile(opts)('node', [testScript], function(err, stdout, stderr) {
err.should.be.an.Error
stdout.should.eql('123\n')
stderr.should.eql('')
done()
})
})
it('buffers everything', function(done) {
it('buffers everything', function(done) {
var opts = {
bufferStdout: true,
bufferStderr: true
}
var opts = {
bufferStdout: true,
bufferStderr: true,
}
var child = execFile(opts)('node', [testScript], function(err, stdout, stderr) {
err.should.be.an.Error
stdout.should.eql('123\n')
stderr.should.containEql('throw new Error(\'error\')')
done()
})
})
var child = execFile(opts)('node', [testScript], function(err, stdout, stderr) {
err.should.be.an.Error
stdout.should.eql('123\n')
stderr.should.containEql('throw new Error(\'error\')')
done()
})
})
})

@@ -7,22 +7,28 @@ // TODO need to find a better way to test the 32bit/64bit specific scenarios

describe('regedit', function () {
var baseKey = 'HKCU\\software\\ironSource\\regedit\\issues-test\\'
var key
var baseKey = 'HKCU\\software\\ironSource\\regedit\\issues-test\\'
var key
// this test fails with a timeout because putValue callback is never invoked
it('putValue with empty string for value fails silently #8', function (done) {
it('putValue with empty string for value fails silently #8', function (done) {
index.createKey(key, function (err) {
if (err) return done(err)
index.createKey(key, function (err) {
if (err) {
return done(err)
}
var values = {}
var values = {}
values[key] = { 'valName': { value: '', type: 'REG_SZ' }}
values[key] = {'valName': {value: '', type: 'REG_SZ'}}
index.putValue(values, function (err) {
if (err) return done(err)
index.putValue(values, function (err) {
if (err) {
return done(err)
}
index.list(key, function(err, results) {
if (err) return done(err)
index.list(key, function(err, results) {
if (err) {
return done(err)
}
results.should.have.property(key)
results.should.have.property(key)
.which.have.property('values')

@@ -32,12 +38,75 @@ .which.have.property('valName')

done()
})
})
})
done()
})
})
})
})
})
beforeEach(function () {
key = baseKey + Date.now()
})
it('can putValue REG_DWORD > 0x7fffffff #21', function (done) {
index.createKey(key, function (err) {
if (err) {
return done(err)
}
var values = {}
values[key] = {'valName': {value: 0x80000000, type: 'REG_DWORD'}}
index.putValue(values, function (err) {
if (err) {
return done(err)
}
index.list(key, function (err, results) {
if (err) {
return done(err)
}
results.should.have.property(key)
.which.have.property('values')
.which.have.property('valName')
.which.have.property('value', 0x80000000)
done()
})
})
})
})
it('can putValue REG_QWORD < 9007199254740993 #21', function (done) {
index.createKey(key, function (err) {
if (err) {
return done(err)
}
var values = {}
values[key] = {'valName': {value: 9007199254740993, type: 'REG_QWORD'}}
index.putValue(values, function (err) {
if (err) {
return done(err)
}
index.list(key, function (err, results) {
if (err) {
return done(err)
}
results.should.have.property(key)
.which.have.property('values')
.which.have.property('valName')
.which.have.property('value', 9007199254740992)
done()
})
})
})
})
beforeEach(function () {
key = baseKey + Date.now()
})
})

@@ -9,11 +9,13 @@ var cp = require('child_process')

describe.skip('json safe stream version', function () {
it('also escapes windows newline', function (done) {
cp.execFile('cscript', ['/NoLogo', vbsScript], function(err, stdout, stderr) {
if (err) return done(err)
it('also escapes windows newline', function (done) {
cp.execFile('cscript', ['/NoLogo', vbsScript], function(err, stdout, stderr) {
if (err) {
return done(err)
}
JSON.parse(stdout).a.should.eql('"' + helper.ESCAPED_WIN_EOL + '测试\\')
JSON.parse(stdout).a.should.eql('"' + helper.ESCAPED_WIN_EOL + '测试\\')
done()
})
})
})
done()
})
})
})
console.log('123')
setTimeout(function () {
throw new Error('error')
}, 1000)
throw new Error('error')
}, 1000)

@@ -0,1 +1,3 @@

/* eslint-disable no-unused-expressions */
var should = require('should')

@@ -5,45 +7,45 @@ var index = require('../index')

describe('list', function () {
this.timeout(5000)
this.timeout(5000)
it('Streaming interface', function (done) {
var testKey = 'hkcu\\software'
it('Streaming interface', function (done) {
var testKey = 'hkcu\\software'
// use non streaming interface to get expected results
index.list(testKey, function (err, expectedResults) {
index.list(testKey, function (err, expectedResults) {
var actualResults = {}
var error
index.list(testKey)
var actualResults = {}
var error
index.list(testKey)
.once('error', function(e) {
should(e).be.an.Error
error = e
})
should(e).be.an.Error
error = e
})
.on('data', function(d) {
actualResults[d.key] = d.data
}).once('finish', function () {
actualResults.should.eql(expectedResults)
done(error)
})
})
})
actualResults[d.key] = d.data
}).once('finish', function () {
actualResults.should.eql(expectedResults)
done(error)
})
})
})
it('works for multiple keys', function (done) {
var actualResults = {}
var keys = ['hklm', 'hkcu']
var error
it('works for multiple keys', function (done) {
var actualResults = {}
var keys = ['hklm', 'hkcu']
var error
// use non streaming interface to get expected results
index.list(keys, function (err, expectedResults) {
index.list(keys)
index.list(keys, function (err, expectedResults) {
index.list(keys)
.once('error', function(e) {
error = e
})
error = e
})
.on('data', function(d) {
actualResults[d.key] = d.data
}).once('finish', function () {
actualResults.should.eql(expectedResults)
done(error)
})
})
})
})
actualResults[d.key] = d.data
}).once('finish', function () {
actualResults.should.eql(expectedResults)
done(error)
})
})
})
})

@@ -0,1 +1,3 @@

/* eslint-disable no-unused-expressions */
// TODO need to find a better way to test the 32bit/64bit specific scenarios

@@ -6,602 +8,692 @@

function toLowerCase (str) {
return str.toLowerCase()
}
describe('regedit', function () {
describe('list keys and values in a sub key', function () {
var target = 'HKLM\\software\\microsoft\\windows\\CurrentVersion'
describe('list keys and values in a sub key', function () {
var target = 'HKLM\\software\\microsoft\\windows\\CurrentVersion'
it(target, function (done) {
index.list(target, function(err, result) {
if (err) return done(err)
it(target, function (done) {
index.list(target, function(err, result) {
if (err) {
return done(err)
}
result.should.have.property(target)
result.should.have.property(target)
var key = result[target]
var key = result[target]
key.should.have.property('keys')
key.should.have.property('values')
key.keys.should.containEql('Policies')
key.values.should.have.property('ProgramFilesDir')
key.values.ProgramFilesDir.should.have.property('value')
key.values.ProgramFilesDir.value.indexOf('C:\\Program Files').should.eql(0)
key.values.ProgramFilesDir.should.have.property('type', 'REG_SZ')
key.should.have.property('keys')
key.should.have.property('values')
key.keys.map(toLowerCase).should.containEql('policies')
key.values.should.have.property('ProgramFilesDir')
key.values.ProgramFilesDir.should.have.property('value')
key.values.ProgramFilesDir.value.indexOf('C:\\Program Files').should.eql(0)
key.values.ProgramFilesDir.should.have.property('type', 'REG_SZ')
done()
})
})
done()
})
})
it(target + ' 32bit', function (done) {
index.arch.list32(target, function(err, result) {
if (err) return done(err)
it(target + ' 32bit', function (done) {
index.arch.list32(target, function(err, result) {
if (err) {
return done(err)
}
result.should.have.property(target)
result.should.have.property(target)
var key = result[target]
var key = result[target]
key.should.have.property('keys')
key.should.have.property('values')
key.keys.should.containEql('Policies')
key.values.should.have.property('ProgramFilesDir')
key.values.ProgramFilesDir.should.have.property('value')
key.values.ProgramFilesDir.value.indexOf('C:\\Program Files').should.eql(0)
key.values.ProgramFilesDir.should.have.property('type', 'REG_SZ')
key.should.have.property('keys')
key.should.have.property('values')
key.keys.map(toLowerCase).should.containEql('policies')
key.values.should.have.property('ProgramFilesDir')
key.values.ProgramFilesDir.should.have.property('value')
key.values.ProgramFilesDir.value.indexOf('C:\\Program Files').should.eql(0)
key.values.ProgramFilesDir.should.have.property('type', 'REG_SZ')
done()
})
})
done()
})
})
it(target + ' 64bit', function (done) {
index.arch.list64(target, function(err, result) {
if (err) return done(err)
it(target + ' 64bit', function (done) {
index.arch.list64(target, function(err, result) {
if (err) {
return done(err)
}
result.should.have.property(target)
result.should.have.property(target)
var key = result[target]
var key = result[target]
key.should.have.property('keys')
key.should.have.property('values')
key.keys.should.containEql('Policies')
key.values.should.have.property('ProgramFilesDir')
key.values.ProgramFilesDir.should.have.property('value', 'C:\\Program Files')
key.values.ProgramFilesDir.should.have.property('type', 'REG_SZ')
key.should.have.property('keys')
key.should.have.property('values')
key.keys.map(toLowerCase).should.containEql('policies')
key.values.should.have.property('ProgramFilesDir')
key.values.ProgramFilesDir.should.have.property('value', 'C:\\Program Files')
key.values.ProgramFilesDir.should.have.property('type', 'REG_SZ')
done()
})
})
done()
})
})
it(target + ' arch auto pick', function (done) {
index.arch.list(target, function(err, result) {
if (err) return done(err)
it(target + ' arch auto pick', function (done) {
index.arch.list(target, function(err, result) {
if (err) {
return done(err)
}
result.should.have.property(target)
result.should.have.property(target)
var key = result[target]
var key = result[target]
key.should.have.property('keys')
key.should.have.property('values')
key.keys.should.containEql('Policies')
key.values.should.have.property('ProgramFilesDir')
key.values.ProgramFilesDir.should.have.property('value', 'C:\\Program Files')
key.values.ProgramFilesDir.should.have.property('type', 'REG_SZ')
key.should.have.property('keys')
key.should.have.property('values')
key.keys.map(toLowerCase).should.containEql('policies')
key.values.should.have.property('ProgramFilesDir')
key.values.ProgramFilesDir.should.have.property('value', 'C:\\Program Files')
key.values.ProgramFilesDir.should.have.property('type', 'REG_SZ')
done()
})
})
done()
})
})
it('can be applied to several independant keys at once', function (done) {
index.list(['hklm', 'hkcu'], function (err, result) {
if (err) return done(err)
it('can be applied to several independant keys at once', function (done) {
index.list(['hklm', 'hkcu'], function (err, result) {
if (err) {
return done(err)
}
result.should.have.property('hklm')
result.hklm.should.have.property('keys')
result.hklm.keys.should.containEql('SOFTWARE')
result.should.have.property('hklm')
result.hklm.should.have.property('keys')
result.hklm.keys.map(toLowerCase).should.containEql('software')
result.should.have.property('hkcu')
result.hkcu.should.have.property('keys')
result.hkcu.keys.should.containEql('Software')
result.should.have.property('hkcu')
result.hkcu.should.have.property('keys')
result.hkcu.keys.map(toLowerCase).should.containEql('software')
done()
})
})
done()
})
})
it('handle spaces in registry keys', function (done) {
var key = 'HKCU\\Keyboard Layout'
it('handle spaces in registry keys', function (done) {
var key = 'HKCU\\Keyboard Layout'
index.list([key], function(err, result) {
result[key].should.have.property('keys')
result[key].keys.should.containEql('Preload')
result[key].keys.should.containEql('Substitutes')
result[key].keys.should.containEql('Toggle')
index.list([key], function(err, result) {
result[key].should.have.property('keys')
result[key].keys.map(toLowerCase).should.containEql('preload')
result[key].keys.map(toLowerCase).should.containEql('substitutes')
result[key].keys.map(toLowerCase).should.containEql('toggle')
done()
})
})
done()
})
})
it.skip('reads unicode characters from the registry - need to manually create', function (done) {
var key = 'HKCU\\software\\ironsource\\'
it.skip('reads unicode characters from the registry - need to manually create', function (done) {
var key = 'HKCU\\software\\ironsource\\'
index.list(key, function(err, result) {
index.list(key, function(err, result) {
if (err) return done(err)
if (err) {
return done(err)
}
result[key].should.have.property('keys')
result[key].keys.should.containEql('测试')
result[key].should.have.property('keys')
result[key].keys.should.containEql('测试')
done()
})
})
done()
})
})
it('will fail for unknown hives', function(done) {
index.list('lala\\software', function(err, result) {
should(err).not.be.null
err.message.should.eql('unsupported hive')
done()
})
})
it('will fail for unknown hives', function(done) {
index.list('lala\\software', function(err, result) {
should(err).not.be.null
err.message.should.eql('unsupported hive')
done()
})
})
it('lists default values', function (done) {
index.list('HKCR\\Directory\\shell\\cmd\\command', function (err, results) {
if (err) return done(err)
results['HKCR\\Directory\\shell\\cmd\\command'].should.have.property('values')
results['HKCR\\Directory\\shell\\cmd\\command'].values.should.have.property('')
done()
})
})
})
it('lists default values', function (done) {
index.list('HKCR\\Directory\\shell\\cmd\\command', function (err, results) {
if (err) {
return done(err)
}
results['HKCR\\Directory\\shell\\cmd\\command'].should.have.property('values')
results['HKCR\\Directory\\shell\\cmd\\command'].values.should.have.property('')
done()
})
})
})
describe('create keys', function () {
var key = 'HKCU\\software\\ironSource\\regedit\\test\\'
var now = Date.now().toString()
describe('create keys', function () {
var key = 'HKCU\\software\\ironSource\\regedit\\test\\'
var now = Date.now().toString()
it('will throw an error if we dont have permission', function (done) {
index.createKey('HKLM\\SECURITY\\unauthorized', function(err, result) {
err.should.be.an.Error
err.message.should.eql('access is denied')
done()
})
})
it('will throw an error if we dont have permission', function (done) {
index.createKey('HKLM\\SECURITY\\unauthorized', function(err, result) {
err.should.be.an.Error
err.message.should.eql('access is denied')
done()
})
})
it(key + now, function (done) {
index.createKey(key + now, function(err) {
if (err) return done(err)
it(key + now, function (done) {
index.createKey(key + now, function(err) {
if (err) {
return done(err)
}
// testing using the module itself is not the best idea...
index.list(key, function(err, result) {
if (err) return done(err)
index.list(key, function(err, result) {
if (err) {
return done(err)
}
result[key].keys.should.containEql(now)
done()
})
})
})
result[key].keys.should.containEql(now)
done()
})
})
})
it(key + now + '测试', function(done) {
index.createKey(key + now + '测试', function (err) {
if (err) return done(err)
it(key + now + '测试', function(done) {
index.createKey(key + now + '测试', function (err) {
if (err) {
return done(err)
}
index.list(key, function (err, results) {
if (err) return done(err)
index.list(key, function (err, results) {
if (err) {
return done(err)
}
results[key].should.have.property('keys')
results[key].keys.should.containEql(now + '测试')
results[key].should.have.property('keys')
results[key].keys.should.containEql(now + '测试')
done()
})
})
})
done()
})
})
})
it(key + now + ' S', function (done) {
index.arch.createKey(key + now, function(err) {
if (err) return done(err)
it(key + now + ' S', function (done) {
index.arch.createKey(key + now, function(err) {
if (err) {
return done(err)
}
// testing using the module itself is not the best idea...
index.arch.list(key, function(err, result) {
if (err) return done(err)
index.arch.list(key, function(err, result) {
if (err) {
return done(err)
}
result[key].keys.should.containEql(now)
done()
})
})
})
result[key].keys.should.containEql(now)
done()
})
})
})
it(key + now + ' 32bit', function (done) {
index.arch.createKey32(key + now, function(err) {
if (err) return done(err)
it(key + now + ' 32bit', function (done) {
index.arch.createKey32(key + now, function(err) {
if (err) {
return done(err)
}
// testing using the module itself is not the best idea...
index.arch.list32(key, function(err, result) {
if (err) return done(err)
index.arch.list32(key, function(err, result) {
if (err) {
return done(err)
}
result[key].keys.should.containEql(now)
done()
})
})
})
result[key].keys.should.containEql(now)
done()
})
})
})
it(key + now + ' 64bit', function (done) {
index.arch.createKey64(key + now, function(err) {
if (err) return done(err)
it(key + now + ' 64bit', function (done) {
index.arch.createKey64(key + now, function(err) {
if (err) {
return done(err)
}
// testing using the module itself is not the best idea...
index.arch.list64(key, function(err, result) {
if (err) return done(err)
index.arch.list64(key, function(err, result) {
if (err) {
return done(err)
}
result[key].keys.should.containEql(now)
done()
})
})
})
result[key].keys.should.containEql(now)
done()
})
})
})
afterEach(function () {
now = Date.now().toString()
})
})
afterEach(function () {
now = Date.now().toString()
})
})
describe('delete keys', function () {
var key = 'HKCU\\software\\ironSource\\regedit\\test\\'
var now = Date.now().toString()
describe('delete keys', function () {
var key = 'HKCU\\software\\ironSource\\regedit\\test\\'
var now = Date.now().toString()
it('will throw an error if we attempt to delete a key without permission', function (done) {
index.deleteKey('HKLM\\SECURITY', function(err) {
err.should.be.an.Error
err.message.should.eql('access is denied')
done()
})
})
it('will throw an error if we attempt to delete a key without permission', function (done) {
index.deleteKey('HKLM\\SECURITY', function(err) {
err.should.be.an.Error
err.message.should.eql('access is denied')
done()
})
})
it(key + now, function (done) {
index.createKey(key + now, function(err) {
if (err) return done(err)
it(key + now, function (done) {
index.createKey(key + now, function(err) {
if (err) {
return done(err)
}
index.list(key, function(err, result) {
if (err) return done(err)
index.list(key, function(err, result) {
if (err) {
return done(err)
}
result[key].keys.should.containEql(now)
result[key].keys.should.containEql(now)
index.deleteKey(key + now, function(err) {
if (err) return done(err)
index.deleteKey(key + now, function(err) {
if (err) {
return done(err)
}
index.list(key, function(err, result1) {
if (err) return done(err)
index.list(key, function(err, result1) {
if (err) {
return done(err)
}
result1.should.not.containEql(now)
done()
})
})
})
})
})
result1.should.not.containEql(now)
done()
})
})
})
})
})
it(key + now + ' S', function (done) {
index.arch.createKey(key + now, function(err) {
if (err) return done(err)
it(key + now + ' S', function (done) {
index.arch.createKey(key + now, function(err) {
if (err) {
return done(err)
}
index.arch.list(key, function(err, result) {
if (err) return done(err)
index.arch.list(key, function(err, result) {
if (err) {
return done(err)
}
result[key].keys.should.containEql(now)
result[key].keys.should.containEql(now)
index.arch.deleteKey(key + now, function(err) {
if (err) return done(err)
index.arch.deleteKey(key + now, function(err) {
if (err) {
return done(err)
}
index.list(key, function(err, result1) {
if (err) return done(err)
index.list(key, function(err, result1) {
if (err) {
return done(err)
}
result1.should.not.containEql(now)
done()
})
})
})
})
})
result1.should.not.containEql(now)
done()
})
})
})
})
})
it(key + now + ' 32bit', function (done) {
index.arch.createKey32(key + now, function(err) {
if (err) return done(err)
it(key + now + ' 32bit', function (done) {
index.arch.createKey32(key + now, function(err) {
if (err) {
return done(err)
}
index.arch.list32(key, function(err, result) {
if (err) return done(err)
index.arch.list32(key, function(err, result) {
if (err) {
return done(err)
}
result[key].keys.should.containEql(now)
result[key].keys.should.containEql(now)
index.arch.deleteKey32(key + now, function(err) {
if (err) return done(err)
index.arch.deleteKey32(key + now, function(err) {
if (err) {
return done(err)
}
index.list(key, function(err, result1) {
if (err) return done(err)
index.list(key, function(err, result1) {
if (err) {
return done(err)
}
result1.should.not.containEql(now)
done()
})
})
})
})
})
result1.should.not.containEql(now)
done()
})
})
})
})
})
it(key + now + ' 64bit', function (done) {
index.arch.createKey64(key + now, function(err) {
if (err) return done(err)
it(key + now + ' 64bit', function (done) {
index.arch.createKey64(key + now, function(err) {
if (err) {
return done(err)
}
index.arch.list64(key, function(err, result) {
if (err) return done(err)
index.arch.list64(key, function(err, result) {
if (err) {
return done(err)
}
result[key].keys.should.containEql(now)
result[key].keys.should.containEql(now)
index.arch.deleteKey64(key + now, function(err) {
if (err) return done(err)
index.arch.deleteKey64(key + now, function(err) {
if (err) {
return done(err)
}
index.list(key, function(err, result1) {
if (err) return done(err)
index.list(key, function(err, result1) {
if (err) {
return done(err)
}
result1.should.not.containEql(now)
done()
})
})
})
})
})
result1.should.not.containEql(now)
done()
})
})
})
})
})
afterEach(function () {
now = Date.now().toString()
})
})
afterEach(function () {
now = Date.now().toString()
})
})
describe('put values', function () {
var key = 'HKCU\\software\\ironSource\\regedit\\test\\'
var now = Date.now().toString()
var map = {}
describe('put values', function () {
var key = 'HKCU\\software\\ironSource\\regedit\\test\\'
var now = Date.now().toString()
var map = {}
it('in ' + key + now, function (done) {
index.putValue(map, function(err) {
if (err) return done(err)
it('in ' + key + now, function (done) {
index.putValue(map, function(err) {
if (err) {
return done(err)
}
index.list(key + now, function(err, result) {
if (err) {
console.error(result)
return done(err)
}
index.list(key + now, function(err, result) {
if (err) {
console.error(result)
return done(err)
}
var values = result[key + now].values
var values = result[key + now].values
values.should.have.property('a key')
values['a key'].type.should.eql('REG_SZ')
values['a key'].value.should.eql('some string')
values.should.have.property('a key')
values['a key'].type.should.eql('REG_SZ')
values['a key'].value.should.eql('some string')
values.should.have.property('b')
values.b.type.should.eql('REG_BINARY')
values.b.value.should.eql([1,2,3])
values.should.have.property('b')
values.b.type.should.eql('REG_BINARY')
values.b.value.should.eql([1, 2, 3])
values.should.have.property('c')
values.c.type.should.eql('REG_DWORD')
values.c.value.should.eql(10)
values.should.have.property('c')
values.c.type.should.eql('REG_DWORD')
values.c.value.should.eql(10)
values.should.have.property('d')
values.d.type.should.eql('REG_QWORD')
values.d.value.should.eql(100)
values.should.have.property('d')
values.d.type.should.eql('REG_QWORD')
values.d.value.should.eql(100)
values.should.have.property('e')
values.e.type.should.eql('REG_EXPAND_SZ')
values.e.value.should.eql('expand_string')
values.should.have.property('e')
values.e.type.should.eql('REG_EXPAND_SZ')
values.e.value.should.eql('expand_string')
values.should.have.property('f')
values.f.type.should.eql('REG_MULTI_SZ')
values.f.value.should.eql(['a', 'b', 'c'])
values.should.have.property('f')
values.f.type.should.eql('REG_MULTI_SZ')
values.f.value.should.eql(['a', 'b', 'c'])
values.should.have.property('测试')
values['测试'].type.should.eql('REG_SZ')
values['测试'].value.should.eql('值 test for non-English environment')
values.should.have.property('测试')
values['测试'].type.should.eql('REG_SZ')
values['测试'].value.should.eql('值 test for non-English environment')
values.should.have.property('newline')
values['newline'].type.should.eql('REG_SZ')
values['newline'].value.should.eql('new\\nline')
values.should.have.property('newline')
values.newline.type.should.eql('REG_SZ')
values.newline.value.should.eql('new\\nline')
done()
})
})
})
done()
})
})
})
it('default value in ' + key + now, function(done) {
var values = {}
values[key + now] = {
'default': {
type: 'reg_default',
value: 'default'
}
}
it('default value in ' + key + now, function(done) {
var values = {}
values[key + now] = {
'default': {
type: 'reg_default',
value: 'default',
},
}
index.putValue(values, function(err) {
index.list(key + now, function (err, results) {
if (err) return done(err)
results[key + now].should.have.property('values')
results[key + now].values.should.have.property('', {
type: 'REG_SZ',
value: 'default'
})
done()
})
})
})
index.putValue(values, function(err) {
index.list(key + now, function (err, results) {
if (err) {
return done(err)
}
results[key + now].should.have.property('values')
results[key + now].values.should.have.property('', {
type: 'REG_SZ',
value: 'default',
})
done()
})
})
})
it('in ' + key + now + ' S', function (done) {
index.arch.putValue(map, function(err) {
if (err) return done(err)
it('in ' + key + now + ' S', function (done) {
index.arch.putValue(map, function(err) {
if (err) {
return done(err)
}
index.arch.list(key + now, function(err, result) {
if (err) return done(err)
var values = result[key + now].values
index.arch.list(key + now, function(err, result) {
if (err) {
return done(err)
}
var values = result[key + now].values
values.should.have.property('a key')
values['a key'].type.should.eql('REG_SZ')
values['a key'].value.should.eql('some string')
values.should.have.property('a key')
values['a key'].type.should.eql('REG_SZ')
values['a key'].value.should.eql('some string')
values.should.have.property('b')
values.b.type.should.eql('REG_BINARY')
values.b.value.should.eql([1,2,3])
values.should.have.property('b')
values.b.type.should.eql('REG_BINARY')
values.b.value.should.eql([1, 2, 3])
values.should.have.property('c')
values.c.type.should.eql('REG_DWORD')
values.c.value.should.eql(10)
values.should.have.property('c')
values.c.type.should.eql('REG_DWORD')
values.c.value.should.eql(10)
values.should.have.property('d')
values.d.type.should.eql('REG_QWORD')
values.d.value.should.eql(100)
values.should.have.property('d')
values.d.type.should.eql('REG_QWORD')
values.d.value.should.eql(100)
values.should.have.property('e')
values.e.type.should.eql('REG_EXPAND_SZ')
values.e.value.should.eql('expand_string')
values.should.have.property('e')
values.e.type.should.eql('REG_EXPAND_SZ')
values.e.value.should.eql('expand_string')
values.should.have.property('f')
values.f.type.should.eql('REG_MULTI_SZ')
values.f.value.should.eql(['a', 'b', 'c'])
values.should.have.property('f')
values.f.type.should.eql('REG_MULTI_SZ')
values.f.value.should.eql(['a', 'b', 'c'])
values.should.have.property('测试')
values['测试'].type.should.eql('REG_SZ')
values['测试'].value.should.eql('值 test for non-English environment')
values.should.have.property('测试')
values['测试'].type.should.eql('REG_SZ')
values['测试'].value.should.eql('值 test for non-English environment')
values.should.have.property('newline')
values['newline'].type.should.eql('REG_SZ')
values['newline'].value.should.eql('new\\nline')
values.should.have.property('newline')
values.newline.type.should.eql('REG_SZ')
values.newline.value.should.eql('new\\nline')
done()
})
})
})
done()
})
})
})
it('in ' + key + now + ' 32bit', function (done) {
index.arch.putValue32(map, function(err) {
if (err) return done(err)
it('in ' + key + now + ' 32bit', function (done) {
index.arch.putValue32(map, function(err) {
if (err) {
return done(err)
}
index.arch.list32(key + now, function(err, result) {
if (err) return done(err)
var values = result[key + now].values
index.arch.list32(key + now, function(err, result) {
if (err) {
return done(err)
}
var values = result[key + now].values
values.should.have.property('a key')
values['a key'].type.should.eql('REG_SZ')
values['a key'].value.should.eql('some string')
values.should.have.property('a key')
values['a key'].type.should.eql('REG_SZ')
values['a key'].value.should.eql('some string')
values.should.have.property('b')
values.b.type.should.eql('REG_BINARY')
values.b.value.should.eql([1,2,3])
values.should.have.property('b')
values.b.type.should.eql('REG_BINARY')
values.b.value.should.eql([1, 2, 3])
values.should.have.property('c')
values.c.type.should.eql('REG_DWORD')
values.c.value.should.eql(10)
values.should.have.property('c')
values.c.type.should.eql('REG_DWORD')
values.c.value.should.eql(10)
values.should.have.property('d')
values.d.type.should.eql('REG_QWORD')
values.d.value.should.eql(100)
values.should.have.property('d')
values.d.type.should.eql('REG_QWORD')
values.d.value.should.eql(100)
values.should.have.property('e')
values.e.type.should.eql('REG_EXPAND_SZ')
values.e.value.should.eql('expand_string')
values.should.have.property('e')
values.e.type.should.eql('REG_EXPAND_SZ')
values.e.value.should.eql('expand_string')
values.should.have.property('f')
values.f.type.should.eql('REG_MULTI_SZ')
values.f.value.should.eql(['a', 'b', 'c'])
values.should.have.property('f')
values.f.type.should.eql('REG_MULTI_SZ')
values.f.value.should.eql(['a', 'b', 'c'])
values.should.have.property('测试')
values['测试'].type.should.eql('REG_SZ')
values['测试'].value.should.eql('值 test for non-English environment')
values.should.have.property('测试')
values['测试'].type.should.eql('REG_SZ')
values['测试'].value.should.eql('值 test for non-English environment')
values.should.have.property('newline')
values['newline'].type.should.eql('REG_SZ')
values['newline'].value.should.eql('new\\nline')
values.should.have.property('newline')
values.newline.type.should.eql('REG_SZ')
values.newline.value.should.eql('new\\nline')
done()
})
})
})
done()
})
})
})
it('in ' + key + now + '64bit', function (done) {
index.arch.putValue64(map, function(err) {
if (err) return done(err)
it('in ' + key + now + '64bit', function (done) {
index.arch.putValue64(map, function(err) {
if (err) {
return done(err)
}
index.arch.list64(key + now, function(err, result) {
if (err) return done(err)
var values = result[key + now].values
index.arch.list64(key + now, function(err, result) {
if (err) {
return done(err)
}
var values = result[key + now].values
values.should.have.property('a key')
values['a key'].type.should.eql('REG_SZ')
values['a key'].value.should.eql('some string')
values.should.have.property('a key')
values['a key'].type.should.eql('REG_SZ')
values['a key'].value.should.eql('some string')
values.should.have.property('b')
values.b.type.should.eql('REG_BINARY')
values.b.value.should.eql([1,2,3])
values.should.have.property('b')
values.b.type.should.eql('REG_BINARY')
values.b.value.should.eql([1, 2, 3])
values.should.have.property('c')
values.c.type.should.eql('REG_DWORD')
values.c.value.should.eql(10)
values.should.have.property('c')
values.c.type.should.eql('REG_DWORD')
values.c.value.should.eql(10)
values.should.have.property('d')
values.d.type.should.eql('REG_QWORD')
values.d.value.should.eql(100)
values.should.have.property('d')
values.d.type.should.eql('REG_QWORD')
values.d.value.should.eql(100)
values.should.have.property('e')
values.e.type.should.eql('REG_EXPAND_SZ')
values.e.value.should.eql('expand_string')
values.should.have.property('e')
values.e.type.should.eql('REG_EXPAND_SZ')
values.e.value.should.eql('expand_string')
values.should.have.property('f')
values.f.type.should.eql('REG_MULTI_SZ')
values.f.value.should.eql(['a', 'b', 'c'])
values.should.have.property('f')
values.f.type.should.eql('REG_MULTI_SZ')
values.f.value.should.eql(['a', 'b', 'c'])
values.should.have.property('测试')
values['测试'].type.should.eql('REG_SZ')
values['测试'].value.should.eql('值 test for non-English environment')
values.should.have.property('测试')
values['测试'].type.should.eql('REG_SZ')
values['测试'].value.should.eql('值 test for non-English environment')
values.should.have.property('newline')
values['newline'].type.should.eql('REG_SZ')
values['newline'].value.should.eql('new\\nline')
values.should.have.property('newline')
values.newline.type.should.eql('REG_SZ')
values.newline.value.should.eql('new\\nline')
done()
})
})
})
done()
})
})
})
beforeEach(function (done) {
index.createKey(key + now, done)
map[key + now] = {
'a key': {
type: 'reg_sz',
value: 'some string'
},
beforeEach(function (done) {
index.createKey(key + now, done)
map[key + now] = {
'a key': {
type: 'reg_sz',
value: 'some string',
},
'b': {
type: 'reg_binary',
value: [1, 2, 3]
},
'b': {
type: 'reg_binary',
value: [1, 2, 3],
},
'c': {
type: 'reg_dword',
value: 10
},
'c': {
type: 'reg_dword',
value: 10,
},
'd': {
type: 'reg_qword',
value: 100
},
'd': {
type: 'reg_qword',
value: 100,
},
'e': {
type: 'reg_expand_sz',
value: 'expand_string'
},
'e': {
type: 'reg_expand_sz',
value: 'expand_string',
},
'f': {
type: 'reg_multi_sz',
value: ['a', 'b', 'c']
},
'f': {
type: 'reg_multi_sz',
value: ['a', 'b', 'c'],
},
'测试': {
type: 'reg_sz',
value: '值 test for non-English environment'
},
'测试': {
type: 'reg_sz',
value: '值 test for non-English environment',
},
'newline': {
type: 'reg_sz',
value: 'new\nline'
}
}
})
'newline': {
type: 'reg_sz',
value: 'new\nline',
},
}
})
afterEach(function () {
now = Date.now().toString()
})
})
afterEach(function () {
now = Date.now().toString()
})
})
})

@@ -0,1 +1,4 @@

/* global errors */
/* eslint-disable max-len */
var e0 = new Error('wbemErrFailed')

@@ -2,0 +5,0 @@ e0.description = 'The call failed.'

var parsed = require('./parsed.json')
for (var i = 0; i < parsed.length; i++) {
var entry = parsed[i]
console.log('var e%d = new Error(\'%s\')', i, entry.error)
console.log('e%d.description = \'%s\'', i, entry.description)
console.log('e%d.code = %d', i, entry.code)
console.log('errors[%d] = e%d', entry.code, i)
}
var entry = parsed[i]
console.log('var e%d = new Error(\'%s\')', i, entry.error)
console.log('e%d.description = \'%s\'', i, entry.description)
console.log('e%d.code = %d', i, entry.code)
console.log('errors[%d] = e%d', entry.code, i)
}

@@ -0,1 +1,3 @@

/* eslint-disable max-len */
var fs = require('fs')

@@ -11,7 +13,9 @@ var START_MARKER = '// *** generated errors ***//'

if (start === -1)
throw new Error('missing injection start marker')
if (start === -1) {
throw new Error('missing injection start marker')
}
if (end === -1)
throw new Error('missing injection end marker')
if (end === -1) {
throw new Error('missing injection end marker')
}

@@ -18,0 +22,0 @@ errorsJs = errorsJs.substring(0, start + START_MARKER.length) + '\n' + generatedErrorObjects + '\n' + errorsJs.substring(end)

@@ -9,17 +9,17 @@ var fs = require('fs')

for (var i = 0; i < errors.length; i++) {
var splitted = errors[i].split('\n')
var splitted = errors[i].split('\n')
var result = {
error: 'wbem' + splitted[0],
code: parseInt(splitted[1]),
description: splitted[2]
}
var result = {
error: 'wbem' + splitted[0],
code: parseInt(splitted[1]),
description: splitted[2],
}
if (result.description) {
result.description = result.description.replace(/'/g, '\\\'')
}
if (result.description) {
result.description = result.description.replace(/'/g, '\\\'')
}
results.push(result)
results.push(result)
}
console.log(JSON.stringify(results))

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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