def init_settings(self):
     """Called from AbbrevCommands.reload_settings aka reloadSettings."""
     c = self.c
     c.k.abbrevOn = c.config.getBool('enable-abbreviations', default=False)
     # Init these here for k.masterCommand.
     c.abbrev_place_end = c.config.getString('abbreviations-place-end')
     c.abbrev_place_start = c.config.getString('abbreviations-place-start')
     c.abbrev_subst_end = c.config.getString('abbreviations-subst-end')
     c.abbrev_subst_env = {
         'c': c,
         'g': g,
         '_values': {},
     }
     # The environment for all substitutions.
     # May be augmented in init_env.
     c.abbrev_subst_start = c.config.getString('abbreviations-subst-start')
     # Local settings.
     self.enabled = (c.config.getBool('scripting-at-script-nodes')
                     or c.config.getBool('scripting-abbreviations'))
     self.globalDynamicAbbrevs = c.config.getBool('globalDynamicAbbrevs')
     # @data abbreviations-subst-env must *only* be defined in leoSettings.leo or myLeoSettings.leo!
     if c.config:
         key = 'abbreviations-subst-env'
         if c.config.isLocalSetting(key, 'data'):
             g.issueSecurityWarning(f"@data {key}")
             self.subst_env = ""
         else:
             self.subst_env = c.config.getData(key, strip_data=False)
Beispiel #2
0
 def __init__(self,c,parent=None):
     QtWidgets.QWidget.__init__(self, parent)
     self.c = c
     self.initUI()
     self.registerCallbacks()
     autoexecute_nodewatch_nodes = c.config.getBool('nodewatch-autoexecute-scripts', default=False)
     if autoexecute_nodewatch_nodes and c.config.isLocalSetting('nodewatch_autoexecute_scripts', 'bool'):
         g.issueSecurityWarning('@bool nodewatch_autoexecute_scripts')
         autoexecute_nodewatch_nodes = False
     if autoexecute_nodewatch_nodes:
         self.update_all()
Beispiel #3
0
 def __init__(self, c, parent=None):
     QtWidgets.QWidget.__init__(self, parent)
     self.c = c
     self.initUI()
     self.registerCallbacks()
     autoexecute_nodewatch_nodes = c.config.getBool(
         'nodewatch-autoexecute-scripts', default=False)
     if autoexecute_nodewatch_nodes and c.config.isLocalSetting(
             'nodewatch_autoexecute_scripts', 'bool'):
         g.issueSecurityWarning('@bool nodewatch_autoexecute_scripts')
         autoexecute_nodewatch_nodes = False
     if autoexecute_nodewatch_nodes:
         self.update_all()
def getData(setting):
    '''Return the given @data node.'''
    # Plug an important security hole.
    c = g.app and g.app.log and g.app.log.c
    key = g.app.config.munge(setting)
    if c and key == 'httpscript' and c.config.isLocalSetting(key, 'data'):
        g.issueSecurityWarning('@data http-script')
        return ""
    aList = g.app.config.getData(
        key,
        strip_comments=False,
        strip_data=False,
    )
    s = ''.join(aList or [])
    return s
Beispiel #5
0
def getData(setting):
    '''Return the given @data node.'''
    # Plug an important security hole.
    c = g.app and g.app.log and g.app.log.c
    key = g.app.config.munge(setting)
    if c and key == 'httpscript' and c.config.isLocalSetting(key, 'data'):
        g.issueSecurityWarning('@data http-script')
        return ""
    aList = g.app.config.getData(
        key,
        strip_comments=False,
        strip_data=False,
    )
    s = ''.join(aList or [])
    return s
    def get_response(self):
        """Return the file like 'f' that leo_interface.send_head makes"""
        # self.request_handler.path.startswith('/_/exec/')

        if not g.app.config.getBool("http-allow-remote-exec"):
            return None  # fail deliberately

        c = g.app and g.app.log and g.app.log.c
        if c and config.enable is None:
            if c.config.isLocalSetting('http-allow-remote-exec', 'bool'):
                g.issueSecurityWarning('@bool http-allow-remote-exec')
                config.enable = False
            else:
                config.enable = True

        parsed_url = urlparse.urlparse(self.request_handler.path)
        query = urlparse.parse_qs(parsed_url.query)

        enc = query.get("enc", ["str"])[0]

        if parsed_url.path.startswith('/_/exec/commanders/'):
            ans = [i.fileName() for i in g.app.commanders()]
            if enc != 'json':
                ans = '\n'.join(ans)
        else:
            ans = self.proc_cmds()

        f = StringIO()
        f.mime_type = query.get("mime_type", ["text/plain"])[0]
        enc = query.get("enc", ["str"])[0]
        if enc == 'json':
            f.write(json.dumps(ans))
        elif enc == 'repr':
            f.write(repr(ans))
        else:
            f.write(str(ans))
        return f
Beispiel #7
0
    def get_response(self):
        """Return the file like 'f' that leo_interface.send_head makes"""
        # self.request_handler.path.startswith('/_/exec/')

        if not g.app.config.getBool("http-allow-remote-exec"):
            return None  # fail deliberately
            
        c = g.app and g.app.log and g.app.log.c
        if c and config.enable is None:
            if c.config.isLocalSetting('http-allow-remote-exec', 'bool'):
                g.issueSecurityWarning('@bool http-allow-remote-exec')
                config.enable = False
            else:
                config.enable = True

        parsed_url = urlparse.urlparse(self.request_handler.path)
        query = urlparse.parse_qs(parsed_url.query)

        enc = query.get("enc", ["str"])[0]

        if parsed_url.path.startswith('/_/exec/commanders/'):
            ans = [i.fileName() for i in g.app.commanders()]
            if enc != 'json':
                ans = '\n'.join(ans)
        else:
            ans = self.proc_cmds()

        f = StringIO()
        f.mime_type = query.get("mime_type", ["text/plain"])[0]
        enc = query.get("enc", ["str"])[0]
        if enc == 'json':
            f.write(json.dumps(ans))
        elif enc == 'repr':
            f.write(repr(ans))
        else:
            f.write(str(ans))
        return f