Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.initialize = function(app, id, options) {
var certificate = null;
// Read SAML certificate if it exists
if (options.certificate) {
if (FS.existsSync(options.certificate))
certificate = FS.readFileSync(options.certificate).toString('ascii');
else
console.log('WARN Certificate ' + options.certificate + ' does not exist!');
}
var params = Util._extend({}, options.params);
options.login = Path.join('/provider', id, 'login');
options.callback = params.path = Path.join('/provider', id, 'callback');
params.cert = certificate;
params.passReqToCallback = true;
Passport.use(id, new SAML(params, function(req, profile, done) {
if (!profile.nameID)
return done(new Error('No identity found in SAML callback payload!'), false);
Model.Provider.findOrCreate({
isSymlink = fileStat.isSymbolicLink(),
isDir = fileStat.isDirectory()
if (isDir || (isSymlink && drillDownSymlinks)) {
await reco.replaceWwwRootDir(filePath)
} else {
await unlinkAsync(filePath)
}
}
}
if (!removeContentOnly)
await rmdirAsync(dirPath);
if (!fs.existsSync('cordova/www')) {
var ncp = require('ncp').ncp;
ncp.limit = 9999999999999;
ncp("./react/build", "./cordova/www", function (err) {
if (err) {
return console.error(err);
}
reco.state.callBack_replaceWwwRootDir(); // callBack();
});
}
},
public copyFileOrFolderSync(source: string, target: string): void {
const skipFolder: boolean = source.endsWith('/*');
if (skipFolder) {
source = source.replace('/*', '');
}
if (source.split('|').length > 1) { // copy with file rename `./path-to-file/old_name.js|new_name.js`
const parts = source.split('|');
source = parts[0];
target = path.join(target, parts[1]);
}
if (fs.existsSync(source)) {
if (fs.lstatSync(source).isDirectory()) {
this.copyFolderRecursiveSync(source, target, skipFolder);
} else {
this.copyFileSync(source, target);
}
}
}
// Setting up media folders for media and tmp media on local file system,
// user libary application support folder
var tmpMediaFolder = path.join(dataPath, 'tmp_media');
var mediaFolder = path.join(dataPath, 'media');
// if media folder does not exists create it
if (!fs.existsSync(tmpMediaFolder)) {
console.debug('tmpMediaFolder folder not present, creating tmpMediaFolder folder');
fs.mkdirSync(tmpMediaFolder);
} else {
// do nothing, build folder was already there
console.debug('tmpMediaFolder folder was already present');
}
// if temp media folder does not exists create it
if (!fs.existsSync(mediaFolder)) {
console.debug('mediaFolder folder not present, creating mediaFolder folder');
fs.mkdirSync(mediaFolder);
} else {
// do nothing, build folder was already there
console.debug('mediaFolder folder was already present');
}
/**
* Create a callback function for LinvoDB queries
* @param {function} success - Success callback
* @param {function} error - Error callback
* @returns {fuction} callback for LinvoDB
*/
function makeLinvoCallback(success, error) {
return function(err, found) {
if (err) {
+ js
+ '\n})(' + namespace + ', ' + JSON.stringify(template) + ');';
append(jsOutput, js, done);
});
// without template
} else {
js = '\n;(function(exports){\n'
+ js
+ '\n})(' + namespace + ');';
append(jsOutput, js, done);
}
});
// style
var css = path.join(lib, name, name + '.css');
if (fs.existsSync(css)) {
read(css, function(err, css){
append(cssOutput, css);
});
}
}
if (process.platform == 'win32') return;
var join = require('path').join,
default_prey_bin = join('/', 'usr','lib','prey','current','bin','prey'),
default_prey_bin_dir = join('/', 'usr','lib','prey','current','bin'),
default_prey_dir = join('/', 'usr','lib','prey'),
fake_prey_filename = join('/', 'tmp', 'b4f9259646c478cccebcf52eccf30a3d_prey'),
ni = require('os').networkInterfaces(),
os_name = process.platform === 'darwin' ? 'mac' : 'linux',
trigger_filename = join(__dirname, '..', 'bin', os_name, 'prey-trigger.py'),
fs = require('fs'),
fsx = require('node-fs'),
spawn = require('child_process').spawn,
utils = require(join(__dirname, 'utils', 'test_utils'));
is_root = process.getuid() === 0,
has_nm_installed = fs.existsSync('/etc/init.d/network-manager');
describe('bin_network_trigger_spec', function(){
if (os_name === 'linux' && !has_nm_installed) {
return describe('when NetworkManager does not exist', function(){
it('exits with error code 1', function(done){
var py_trigger = spawn(trigger_filename, ['-b', fake_prey_filename]);
py_trigger.on('close', function(code){
code.should.be.equal(1);
done();
});
});
function sendapp(){
if (!fs.existsSync(appDeliveryDir + "/Deliverfile")){
console.log(chalk.red('You need to initialize the "deliver" settings.'));
program.help();
return;
}
var newFileContents = "";
var _hasipa = false;
fs.readFileSync(deliverFile).toString().split('\n').forEach(function (line) {
if( /^ipa /.test(line) ){
_hasipa = true;
newFileContents = newFileContents + 'ipa "../../build/' + tiapp.name + '.ipa"' + "\n";
}
else{
newFileContents = newFileContents + line + "\n";
var writeContents = function (copyFile, options, cb) {
var to = copyFile.to,
intendedFrom = copyFile.intendedFrom;
var contents = options.contents,
uglified = options.uglified,
overwriteIfFileAlreadyExists = options.overwriteIfFileAlreadyExists;
utils.ensureDirectoryExistence(to);
var fileExists = fs.existsSync(to),
fileDoesNotExist = !fileExists;
var avoidedFileOverwrite;
var finalPath = '';
if (
fileDoesNotExist ||
(fileExists && overwriteIfFileAlreadyExists)
) {
try {
if (to[to.length-1] === '/') {
var stats = fs.statSync(to);
if (stats.isDirectory()) {
if (typeof intendedFrom === 'string' && !isGlob(intendedFrom)) {
var fileName = path.basename(intendedFrom);
to = unixify(path.join(to, fileName));
}
function getFile(filename) {
if (Object.values(PATHS).indexOf(filename) === -1) {
throw new Error(`Path not allowed: ${filename}`);
}
const fullPath = filename.match(/^\.\//) ?
path.join(path.resolve(__dirname, '../../', filename)) :
require.resolve(filename);
if (!fs.existsSync(fullPath)) {
throw new Error(`File '${filename}' cannot be found. Location: '${fullPath}'`);
}
return fs.readFileSync(fullPath, {encoding: 'utf8'});
}
function exists(file) {
return fs.existsSync(file);
}