コード例 #1
0
    def test_custom_schema(self):
        query = 'SELECT * FROM custom_table;'
        assert validate_osquery_query(query) is False

        try:
            # This is a bit hacky, but it clears the mock DB so the next call
            # will re-create it.
            osquery_mock_db.db = None

            current_app.config['DOORMAN_EXTRA_SCHEMA'].append(
                'CREATE TABLE custom_table (id INTEGER);'
            )
            assert validate_osquery_query(query) is True
        finally:
            # Remove final entry from the config.
            current_app.config['DOORMAN_EXTRA_SCHEMA'] = \
                current_app.config['DOORMAN_EXTRA_SCHEMA'][:-1]
コード例 #2
0
ファイル: test_utils.py プロジェクト: isabella232/doorman-1
 def test_bad_table(self):
     query = 'SELECT * FROM a_table_that_does_not_exist;'
     assert validate_osquery_query(query) is False
コード例 #3
0
ファイル: test_utils.py プロジェクト: isabella232/doorman-1
 def test_syntax_error(self):
     query = 'SELECT * FROM'
     assert validate_osquery_query(query) is False
コード例 #4
0
ファイル: test_utils.py プロジェクト: isabella232/doorman-1
 def test_complex_validate(self):
     # From Facebook's blog post: https://code.facebook.com/posts/844436395567983/introducing-osquery/
     query = 'SELECT DISTINCT process.name, listening.port, listening.address, process.pid FROM processes AS process JOIN listening_ports AS listening ON process.pid = listening.pid;'
     assert validate_osquery_query(query) is True
コード例 #5
0
ファイル: test_utils.py プロジェクト: isabella232/doorman-1
 def test_simple_validate(self):
     query = 'SELECT * FROM osquery_info;'
     assert validate_osquery_query(query) is True
コード例 #6
0
ファイル: forms.py プロジェクト: efueger/doorman
 def __call__(self, form, field):
     if not validate_osquery_query(field.data):
         raise ValidationError(self.message)
コード例 #7
0
 def __call__(self, form, field):
     if not validate_osquery_query(field.data):
         raise ValidationError(self.message)