403Webshell
Server IP : 54.250.94.235  /  Your IP : 216.73.216.57
Web Server : Apache
System : Linux ip-172-26-8-22 6.1.0-41-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.158-1 (2025-11-09) x86_64
User : bitnami ( 1000)
PHP Version : 8.2.28
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /opt/bitnami/nami/lib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/bitnami/nami/lib/arguments_handler.js
"use strict";
/*
 * Copyright VMware, Inc.
 * SPDX-License-Identifier: GPL-2.0-only
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.ArgumentHandler = void 0;
/**
 * Class for handling definition arguments based on the provisioner values
 */
class ArgumentHandler {
    /**
     * Create instance of arguments handler
     * @param argumentsDefinition   definition of the arguments to handle
     * @param provisioner           provisioner instance keeping the values to map
     * @param logger                internal logger
     */
    constructor(argumentsDefinition, provisioner, logger) {
        /**
         * Provisioner map
         * Maps function-keys to function-values
         */
        this.provisionerMap = {
            instanceData: () => this.provisioner.instanceData,
            localAddress: () => this.provisioner.localAddressHostname,
            peerPassword: () => this._getPeerPassword,
            shortPeerPassword: () => this._getShortPeerPassword,
            appUsername: () => this.provisioner.defaultOrAppUsername,
            appPassword: () => this.provisioner.defaultOrAppPassword,
            shortAppPassword: () => this.provisioner.defaultOrAppPassword.substring(0, 16),
            appDatabase: () => this.provisioner.defaultOrAppDatabase,
            persistentNode: () => this.provisioner.defaultOrPersistentNode,
            booleanInput: () => this.provisioner.defaultOrBooleanInput,
            configOverrides: () => this.provisioner.defaultOrConfigOverrides,
            publicEndpoint: () => this.provisioner.defaultOrPublicEndpoint,
        };
        /**
         * Digest map
         * Maps function-keys to function-values
         */
        this.digestMap = {
            join: (ha) => this.join(ha.join),
            concat: (ha) => this.concat(ha.concat),
            value: (ha) => this.value(ha),
            generatePassword: (ha) => this.generatePassword(ha.generatePassword),
            modifiers: (ha) => "",
        };
        this.argumentsDefinition = argumentsDefinition;
        this.provisioner = provisioner;
        this._logger = logger;
    }
    /**
     * Instance of logger
     */
    get logger() {
        return this._logger;
    }
    /**
     * Render argument
     */
    renderArgument(argument) {
        if (typeof argument === "string") {
            return argument.toString();
        }
        else {
            return Object.keys(argument).map(k => this.digest(argument, k)).join("");
        }
    }
    /**
     * Join values within a separator
     * @param object containing the data to join
     * @param object.separator to join with
     * @param object.values    to join
     */
    join(object) {
        if (!object.values || object.values.length === 0) {
            throw new Error(`Unexpected 'join' argument with an empty 'values' property`);
        }
        const separator = object.separator ? object.separator : ",";
        return object.values.map(arg => this.renderArgument(arg)).join(separator);
    }
    /**
     * Concat an array of items
     * @param array of items to concat
     */
    concat(array) {
        return array.map(arg => this.renderArgument(arg)).join("");
    }
    /**
     * Get the provisioner value mapped to a item
     * @param item           to get the value from provisioner
     * @param item.value     to get from provisioner
     * @param item.modifiers to perform in certain values
     */
    value(item) {
        const value = item.value;
        const fnc = this.provisionerMap[value];
        if (fnc == null) {
            throw new Error(`Unable to handle '${value}' provisioner mapping.`);
        }
        return fnc(item);
    }
    /**
     * Get deployment peer password
     */
    get _getPeerPassword() {
        this.provisioner.warnIfPeerPasswordNotSet();
        return this.provisioner.defaultOrPeerPassword;
    }
    /**
     * Get deployment short peer password
     */
    get _getShortPeerPassword() {
        this.provisioner.warnIfPeerPasswordNotSet();
        return this.provisioner.defaultOrPeerPassword.substring(0, 16);
    }
    /**
     * Generate a password from a seed (shared-unique-id).
     * If specified, it can be encoded as a fernet key.
     * @param prefix to use to form a shared unique ID
     * @param type is used to define the format of the generated password
     */
    generatePassword(arg) {
        let prefix = "";
        let type = "";
        if (typeof arg === "string") {
            prefix = arg;
        }
        else {
            prefix = arg.prefix;
            type = arg.type;
        }
        let password = this.provisioner.getDerivedSharedUniqueId(prefix);
        if (type === "fernet") {
            password = this.provisioner.getDerivedFernetKey(password || "");
        }
        return password;
    }
    /**
     * Digest an argument based on a given function
     * @param hashArgument to digest
     * @param fn           function to apply
     */
    digest(hashArgument, fn) {
        const fnc = this.digestMap[fn];
        if (fnc == null) {
            throw new Error(`Invalid property '${fn}' in object: ${JSON.stringify(hashArgument)}`);
        }
        return fnc(hashArgument);
    }
    /**
     * Arguments rendering
     */
    get arguments() {
        if (!this._arguments) {
            this._arguments = this.argumentsDefinition.map(arg => this.renderArgument(arg));
        }
        return this._arguments;
    }
}
exports.ArgumentHandler = ArgumentHandler;

Youez - 2016 - github.com/yon3zu
LinuXploit