MOON
Server: Apache
System: Linux 54-179-220-51.cprapid.com 3.10.0-1160.144.1.el7.tuxcare.els4.x86_64 #1 SMP Tue Apr 7 08:40:40 UTC 2026 x86_64
User: thehunarfound (1001)
PHP: 7.4.29
Disabled: NONE
Upload Files
File: /home/thehunarfound/public_html/DMS/node_modules/snyk-php-plugin/lib/system_deps.js
var _ = require('lodash');
var cmds = require('./composer_cmds.js');

function isSet(variable) {
  return typeof variable !== 'undefined';
}

function systemDeps(basePath, options) {
  var composerOk = isSet(options.composerIsFine) ?
    options.composerIsFine : cmds.cmdReturnsOk(cmds.composerCmd);
  var composerPharOk = isSet(options.composerPharIsFine) ?
    options.composerPharIsFine : cmds.cmdReturnsOk(cmds.pharCmd);

  var finalVersionsObj = {};

  if (options.systemVersions &&
    (Object.keys(options.systemVersions).length > 0)) {
    // give first preference to a stub
    finalVersionsObj = options.systemVersions;
  } else if (composerOk) {
    var lines = cmds.execWithResult(cmds.composerShowCmd, basePath).split('\n');
    lines.forEach(function(line) {
      var parts = line.split(/\s+/);
      if (parts.length > 1) {
        finalVersionsObj[parts[0]] = parts[1];
      }
    });
  } else if (composerPharOk) {
    var output = cmds.execWithResult(cmds.pharCmd, basePath);
    var versionsObj = JSON.parse(output).platform;
    _.forEach(versionsObj, function(value) {
      finalVersionsObj[value.name] = value.version;
    });
  } else {
    // TODO: we want to tell the user we are not reporting accurately system
    // versions, so some version information may not be exact
  }
  return finalVersionsObj;
}

module.exports = {
  systemDeps: systemDeps,
};
;;