示例#1
0
    def configuration_dump(self, context, event, response, cacheddata):
        response["statusCode"] = 200
        is_yaml = "format" in event and event["format"].lower() == "yaml"
        with_maintenance_window = "with_maintenance_window" in event and event[
            "with_maintenance_window"].lower() == "true"
        if with_maintenance_window:
            # We load the EC2 and SSM modules to inherit their override parameters if a SSM Maintenance Window is active
            misc.load_prerequisites(self.context, ["o_ec2", "o_ssm"])

        if "httpMethod" in event and event["httpMethod"] == "POST":
            try:
                c = yaml.safe_load(event["body"]) if is_yaml else json.loads(
                    event["body"])
                Cfg.import_dict(c)
                response["body"] = "Ok (%d key(s) processed)" % len(c.keys())
            except Exception as e:
                response["statusCode"] = 500
                response["body"] = "Can't parse YAML/JSON document : %s " % e
                return False
        else:
            only_stable_keys = "unstable" not in event or event[
                "unstable"].lower() != "true"
            if "raw" in event and event["raw"].lower() == "true":
                dump = Cfg.get_dict()
            else:
                dump = config.dumps(only_stable_keys=only_stable_keys)
            response["body"] = yaml.dump(dump) if is_yaml else Dbg.pprint(dump)
        return True
示例#2
0
文件: agent.py 项目: mishudark/Hotot
def crack_config(params):
    if params[1] == 'dumps':
        config.dumps()
    elif params[1] == 'loads': # useless
        config.loads()
    elif params[1] == 'push_prefs':
        config.loads()
        push_prefs()
    elif params[1] == 'save_prefs':
        prefs = db.unserialize_dict(params[2])
        config.save_prefs(prefs)
        apply_prefs()
    elif params[1] == 'restore_defaults':
        config.restore_defaults()
        apply_config()
        push_prefs()
    elif params[1] == 'set_opts':
        opts = json.loads(urllib2.unquote(params[2]))
        for key, value in opts.items():
            config.set(key, value)
    pass
示例#3
0
文件: agent.py 项目: mishudark/Hotot
def crack_exts(params):
    if params[1] == 'save_enabled':
        exts_enabled = json.loads(urllib2.unquote(params[2]))
        config.set('exts_enabled', exts_enabled)
        config.dumps()
    pass
 def dump_configuration(self, context, event, response):
     response["statusCode"] = 200
     response["body"]       = Dbg.pprint(config.dumps())