OLD SHORTCUT for Security->getAccount->hasModule()
184903
public static function hasModule(string $module=null) :bool {
		// if module is in our credentials
		return self::$_account ? 
			self::getAccount()->hasModule($module) : false;
	}
302367
def isModule(self, dotted_name, extrapath=None):
        """"""
        try:
            return self._module_cache[(dotted_name, extrapath)]
        except KeyError:
            pass
        if dotted_name in sys.modules or dotted_name in self.builtin_modules:
            return dotted_name
        filename = dotted_name.replace('.', os.path.sep)
        if extrapath:
            for ext in self._exts:
                candidate = os.path.join(extrapath, filename) + ext
                if os.path.exists(candidate):
                    modname = self.filenameToModname(candidate)
                    self._module_cache[(dotted_name, extrapath)] = modname
                    return modname
        try:
            return self._module_cache[(dotted_name, None)]
        except KeyError:
            pass
        for dir in self.path:
            if os.path.isfile(dir):
                if dir.endswith('.egg-info'):
                    # distribute creates a setuptools-blah-blah.egg-info
                    # that ends up in sys.path
                    continue
                try:
                    zf = zipfile.ZipFile(dir)
                except zipfile.BadZipfile:
                    self.warn(dir, "%s: not a directory or zip file", dir)
                    continue
                names = zf.namelist()
                for ext in self._exts:
                    candidate = filename + ext
                    if candidate in names:
                        modname = filename.replace(os.path.sep, '.')
                        self._module_cache[(dotted_name, extrapath)] = modname
                        self._module_cache[(dotted_name, None)] = modname
                        return modname
            else:
                for ext in self._exts:
                    candidate = os.path.join(dir, filename) + ext
                    if os.path.exists(candidate):
                        modname = self.filenameToModname(candidate)
                        self._module_cache[(dotted_name, extrapath)] = modname
                        self._module_cache[(dotted_name, None)] = modname
                        return modname
        return None
914940
function is_addon_activated( $id_or_slug, $is_premium = null ) {
            $this->_logger->entrance();

            $addon_id     = self::get_module_id( $id_or_slug );
            $is_activated = self::has_instance( $addon_id );

            if ( ! $is_activated ) {
                return false;
            }

            if ( is_bool( $is_premium ) ) {
                // Check if the specified code version is activate.
                $addon        = $this->get_addon_instance( $addon_id );
                $is_activated = ( $is_premium === $addon->is_premium() );
            }

            return $is_activated;
        }
886800
static function checkDebugByUser()
    {
        if ( !isset( $GLOBALS['eZDebugUserIDList'] ) ||
             !is_array( $GLOBALS['eZDebugUserIDList'] ) )
        {
            return false;
        }
        else
        {
            $currentUserID = eZUser::currentUserID();

            if ( !$currentUserID )
            {
                return false;
            }
            else
            {
                $GLOBALS['eZDebugAllowedByUser'] = in_array( $currentUserID, $GLOBALS['eZDebugUserIDList'] );

                if ( $GLOBALS['eZDebugAllowed'] )
                {
                    $GLOBALS['eZDebugAllowed'] = $GLOBALS['eZDebugAllowedByUser'];
                }

                if ( $GLOBALS['eZDebugEnabled'] )
                {
                    $GLOBALS['eZDebugEnabled'] = $GLOBALS['eZDebugAllowedByUser'];
                }

                unset( $GLOBALS['eZDebugUserIDList'] );

                return true;
            }
        }
    }
154605
def __get_acl(self, load):
        '''
        
        '''
        if 'eauth' not in load:
            return None
        mod = self.opts['eauth_acl_module']
        if not mod:
            mod = load['eauth']
        fstr = '{0}.acl'.format(mod)
        if fstr not in self.auth:
            return None
        fcall = salt.utils.args.format_call(
            self.auth[fstr],
            load,
            expected_extra_kws=AUTH_INTERNAL_KEYWORDS)
        try:
            return self.auth[fstr](*fcall['args'], **fcall['kwargs'])
        except Exception as e:
            log.debug('Authentication module threw %s', e)
            return None
456225
function initModule(forge) {

// shortcut for asn.1 API
var asn1 = forge.asn1;

/* Public Key Infrastructure (PKI) implementation. */
var pki = forge.pki = forge.pki || {};

/**
 * NOTE: THIS METHOD IS DEPRECATED. Use pem.decode() instead.
 *
 * Converts PEM-formatted data to DER.
 *
 * @param pem the PEM-formatted data.
 *
 * @return the DER-formatted data.
 */
pki.pemToDer = function(pem) {
  var msg = forge.pem.decode(pem)[0];
  if(msg.procType && msg.procType.type === 'ENCRYPTED') {
    throw new Error('Could not convert PEM to DER; PEM is encrypted.');
  }
  return forge.util.createBuffer(msg.body);
};

/**
 * Converts an RSA private key from PEM format.
 *
 * @param pem the PEM-formatted private key.
 *
 * @return the private key.
 */
pki.privateKeyFromPem = function(pem) {
  var msg = forge.pem.decode(pem)[0];

  if(msg.type !== 'PRIVATE KEY' && msg.type !== 'RSA PRIVATE KEY') {
    var error = new Error('Could not convert private key from PEM; PEM ' +
      'header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');
    error.headerType = msg.type;
    throw error;
  }
  if(msg.procType && msg.procType.type === 'ENCRYPTED') {
    throw new Error('Could not convert private key from PEM; PEM is encrypted.');
  }

  // convert DER to ASN.1 object
  var obj = asn1.fromDer(msg.body);

  return pki.privateKeyFromAsn1(obj);
};

/**
 * Converts an RSA private key to PEM format.
 *
 * @param key the private key.
 * @param maxline the maximum characters per line, defaults to 64.
 *
 * @return the PEM-formatted private key.
 */
pki.privateKeyToPem = function(key, maxline) {
  // convert to ASN.1, then DER, then PEM-encode
  var msg = {
    type: 'RSA PRIVATE KEY',
    body: asn1.toDer(pki.privateKeyToAsn1(key)).getBytes()
  };
  return forge.pem.encode(msg, {maxline: maxline});
};

/**
 * Converts a PrivateKeyInfo to PEM format.
 *
 * @param pki the PrivateKeyInfo.
 * @param maxline the maximum characters per line, defaults to 64.
 *
 * @return the PEM-formatted private key.
 */
pki.privateKeyInfoToPem = function(pki, maxline) {
  // convert to DER, then PEM-encode
  var msg = {
    type: 'PRIVATE KEY',
    body: asn1.toDer(pki).getBytes()
  };
  return forge.pem.encode(msg, {maxline: maxline});
};

}
517778
def auth_from_hass_config(path=None, **kwargs):
    """"""
    if path is None:
        path = config.find_hass_config()

    return Auth(os.path.join(path, ".storage/auth"), **kwargs)
1313157
protected function checkModule() : void
    {
        $namespaced_class = $this->getFullyQualifiedClass($this->response->getModule(), $this->response->getController());
        if (!class_exists($namespaced_class)) {
            $this->response->setStatusCode(404);
            Core::i()->log->warning('Unable to load controller ' . $namespaced_class);
            return;
        }
        if (!call_user_func($namespaced_class . '::can_view')) {
            $this->response->setStatusCode(403);
            Core::i()->log->error('User is not authorized to view ' . $namespaced_class);
            return;
        }
        if (method_exists($namespaced_class, $this->getActionMethodName($this->response->getAction()))) {
            $this->response->setStatusCode(200);
        } elseif (method_exists($namespaced_class, 'indexAction')) {
            Core::i()->log->notice('Requested action ' . $this->response->getAction() . ' not found in ' . $namespaced_class);
            $this->response->setAction('index');
            $this->response->setStatusCode(200);
        } else {
            Core::i()->log->error('Controller ' . $namespaced_class . ' does not have a public indexAction method defined.');
            $this->response->setStatusCode(500);
        }
    }
1347894
function findModuleNameByInteractive() {
        var scripts = document.getElementsByTagName('script'),
            re,
            i,
            name,
            script;

        for (i = scripts.length - 1; i >= 0; i--) {
            script = scripts[i];
            if (script.readyState === 'interactive') {
                re = script;
                break;
            }
        }
        if (re) {
            name = re.getAttribute('data-mod-name');
        } else {
            // sometimes when read module file from cache,
            // interactive status is not triggered
            // module code is executed right after inserting into dom
            // i has to preserve module name before insert module script into dom,
            // then get it back here
            logger.debug('can not find interactive script,time diff : ' + (+new Date() - startLoadModTime));
            logger.debug('old_ie get mod name from cache : ' + startLoadModName);
            name = startLoadModName;
        }
        return name;
    }
288527
function allowModule (args) {
    // validate args
    this.requireValidArgsModule(args)
    // start new audit
    this.newAudit(args, 'module')
    // get access rules
    var rules = this.getRules('module')
    // if no rules exist for modules then default to allow
    if (!rules) {
        return this.audit.setAllow(true)
    }
    // get roles from session or use defaults
    var roles = this.getRoles(args.session)
    // default to allow
    var allow = true
    // check global rules
    if (rules.allow) {
        allow = this.isRoleAllowed(allow, roles, rules.allow, false, 'global')
    }
    // get module specific rules
    rules = rules.module && rules.module[args.module]
    // if there are no module specific rules then return current allow
    if (!rules) {
        return this.audit.setAllow(allow)
    }
    // check module specific rule
    if (rules.allow) {
        allow = this.isRoleAllowed(allow, roles, rules.allow, false, 'module')
    }
    // get method specific rules
    rules = rules.method && rules.method[args.method]
    // if there are no method specific rules then return current allow
    if (!rules) {
        return this.audit.setAllow(allow)
    }
    // check method specific rule
    if (rules.allow) {
        allow = this.isRoleAllowed(allow, roles, rules.allow, false, 'method')
    }

    return this.audit.setAllow(allow)
}
1137143
public function installAction($name, $module, $hasTable = false, $hasSeed = false, $hasAssets = false, $isGlobal = false) {
        $methods = [];
        if ($hasTable) {
            $methods[] = 'install';
        }
        if ($hasSeed) {
            $methods[] = 'seeder';
        }
        $module = trim($module);
        $this->invokeModuleMethod($module, $methods);
        $this->saveModuleConfigs([
            'modules' => [
                $name => $module
            ]
        ], $isGlobal);
        if ($hasAssets) {
            $this->moveAssets($module);
        }
        return $this->jsonSuccess();
    }
2331
function is_addon_connected( $id_or_slug ) {
            $this->_logger->entrance();

            $sites = self::get_all_sites( WP_FS__MODULE_TYPE_PLUGIN );

            $addon_id = self::get_module_id( $id_or_slug );
            $addon    = $this->get_addon( $addon_id );
            $slug     = $addon->slug;
            if ( ! isset( $sites[ $slug ] ) ) {
                return false;
            }

            $site = $sites[ $slug ];

            $plugin = FS_Plugin_Manager::instance( $addon_id )->get();

            if ( $plugin->parent_plugin_id != $this->_plugin->id ) {
                // The given slug do NOT belong to any of the plugin's add-ons.
                return false;
            }

            return ( is_object( $site ) &&
                     is_numeric( $site->id ) &&
                     is_numeric( $site->user_id ) &&
                     FS_Plugin_Plan::is_valid_id( $site->plan_id )
            );
        }
771374
private Long getAccountIdArg(Object[] arguments) {
        if (arguments.length <= ACCT_ID_INDEX) {
            log.error("Illegal number of args: " + arguments.length);
        }
        return (Long) arguments[ACCT_ID_INDEX];
    }
521174
function loadAndDescribeModuleInCwd() {
// Hack: Trick node into changing process.mainScript to moduleToDebug
  moduleToDebug = Module._load(location, module, true);

  var sample = getSampleCommand();
  sampleLine = util.format('You can access your module as `m`%s.', sample);

  prompt = getModuleName() + '> ';
}
758764
function hasAccessToView( $module, $viewName, &$params )
    {
        $validView = false;
        $accessAllowed = false;
        if ( $module->singleFunction() )
        {
            $info = $module->attribute( 'info' );
            if ( isset( $info['function'] ) )
            {
                $validView = true;
                if ( isset( $info['function']['functions'] ) && !empty( $info['function']['functions'] ) )
                {
                    $functions = $info['function']['functions'];
                }
            }
        }
        else
        {
            $views = $module->attribute( 'views' );
            if ( isset( $views[$viewName] ) )
            {
                $view = $views[$viewName];
                $validView = true;
                if ( isset( $view['functions'] ) && !empty( $view['functions'] ) )
                {
                    $functions = $view['functions'];
                }
            }
        }

        if ( $validView )
        {
            if ( isset( $functions ) )
            {
                if ( is_array( $functions ) )
                {
                    $funcExpression = false;
                    $accessAllowed = true;
                    foreach ( $functions as $function )
                    {
                        if ( empty( $function ) )
                        {
                            $funcExpression = false;
                            $accessAllowed = false;
                            break;
                        }
                        else if ( is_string( $function ) )
                        {
                            if ( $funcExpression )
                            {
                                $funcExpression .= ' and ';
                            }
                            $funcExpression .= '( ' . $function . ' )';
                        }
                    }
                }
                else if ( is_string( $functions ) )
                {
                    $funcExpression = $functions;
                }
                else
                {
                    $funcExpression = false;
                    $accessAllowed = true;
                }

                if ( $funcExpression )
                {
                    // Validate and evaluate functions expression.
                    // Lets construct functions's expression ready for evaluating first.
                    $pS = '/(?<=\b)';
                    $pE = '(?=\b)/';

                    $moduleName = $module->attribute( 'name' );
                    $availableFunctions = $module->attribute( 'available_functions' );
                    if ( is_array( $availableFunctions ) and
                         !empty( $availableFunctions ) )
                    {
                        $pattern = $pS . '(' . implode( '|', array_keys( $availableFunctions ) ) . ')' . $pE;
                        $matches = array();
                        if ( preg_match_all( $pattern, ' ' . $funcExpression . ' ', $matches ) > 0 )
                        {
                            $patterns = array();
                            $replacements = array();
                            $matches = array_unique( $matches[1] );
                            foreach ( $matches as $match )
                            {
                                if ( !isset( $replacements[$match] ) )
                                {
                                    $accessResult = $this->hasAccessTo( $moduleName, $match );
                                    if ( $accessResult['accessWord'] == 'no' )
                                    {
                                        $replacements[$match] = 'false';
                                        $params['accessList'] = $accessResult['accessList'];
                                    }
                                    else
                                    {
                                        $replacements[$match] = 'true';
                                        if ( $accessResult['accessWord'] == 'limited' )
                                        {
                                            $params['Limitation'] = $accessResult['policies'];
                                            $GLOBALS['ezpolicylimitation_list'][$this->ContentObjectID][$moduleName][$match] = $params['Limitation'];
                                        }
                                    }
                                    $patterns[$match] = $pS . $match . $pE;
                                }
                            }
                            $funcExpression = preg_replace( $patterns, $replacements, ' ' . $funcExpression . ' ' );
                        }
                    }
                    $funcExpressionForEval = $funcExpression;

                    // continue to validate expression
                    $words = array();
                    $words[] = $pS . 'and' . $pE;
                    $words[] = $pS . 'or' . $pE;
                    $words[] = $pS . 'true' . $pE;
                    $words[] = $pS . 'false' . $pE;
                    $pS = '/(?<=[^&|])';
                    $pE = '(?=[^&|])/';
                    $words[] = $pS . '\|\|' . $pE;
                    $words[] = $pS . '&&' . $pE;
                    $words[] = '/[\(\)]/';

                    $replacement = '';
                    $funcExpression = preg_replace( $words, $replacement, ' ' . $funcExpression . ' ' );

                    $funcExpression = trim( $funcExpression );

                    if ( empty( $funcExpression ) )
                    {
                        // if expression is valid then evaluate value of the $functionsToEvaluate string
                        ob_start();
                        $ret = eval( "\$accessAllowed = ( bool ) ( $funcExpressionForEval );" );
                        $buffer = ob_get_contents();
                        ob_end_clean();

                        // if we get any error while evaluating then set result to false
                        if ( !empty( $buffer ) or $ret === false )
                        {
                            eZDebug::writeError( "There was an error while evaluating the policy functions value of the '$moduleName/$viewName' view. " .
                                                 "Please check the '$moduleName/module.php' file." );
                            $accessAllowed = false;
                        }
                    }
                    else
                    {
                        eZDebug::writeError( "There is a mistake in the functions array data of the '$moduleName/$viewName' view. " .
                                             "Please check the '$moduleName/module.php' file." );
                        $accessAllowed = false;
                    }
                }
            }
            else
            {
                $moduleName = $module->attribute( 'name' );
                $accessResult = $this->hasAccessTo( $moduleName );
                if ( $accessResult['accessWord'] == 'no' )
                {
                    $params['accessList'] = $accessResult['accessList'];
                    $accessAllowed = false;
                }
                else
                {
                    $accessAllowed = true;
                    if ( $accessResult['accessWord'] == 'limited' )
                    {
                        $params['Limitation'] = $accessResult['policies'];
                        $GLOBALS['ezpolicylimitation_list'][$this->ContentObjectID][$moduleName]['*'] = $params['Limitation'];
                    }
                }
            }
        }

        return $accessAllowed;
    }
981754
function getModulesAnswered(command, argv, globs) {
  let modulesCalled = {};
  let modulesAnswered = [];

  globs.forEach(pkg => {
    const dirName = path.dirname(pkg);
    let pkgJson = {};
    let module;

    try {
      module = require(dirName);
      pkgJson = require(pkg);
    } catch (err) {
      logger.verbose(`Error loading module: ${pkg}`);
    }

    if (module && typeof module.runCommand === 'function') {
      const pkgName = pkgJson.name || dirName;

      if (modulesCalled[pkgName]) {
        logger.verbose(`Multiple instances found. Skipping passing command to ${pkgName}`);
      } else {
        logger.verbose(`Passing command to ${pkgName}`);

        modulesCalled[pkgName] = true;
        if (module.runCommand(command, argv)) {
          modulesAnswered.push(pkgName);
        }

      }
    }
  });

  return modulesAnswered;
}
465276
private static function auth()
    {
        $files = ['Auth'];
        $folder = static::$root.'Authentication'.'/';

        self::call($files, $folder);

        $files = ['AuthenticationModelNotFoundException'];
        $folder = static::$root.'Authentication/Exceptions'.'/';

        self::call($files, $folder);
    }