Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multi-query support for "-q " and "-v" flag. #25

Merged
merged 3 commits into from
Jan 22, 2024

Conversation

MelaElezaj
Copy link
Contributor

This PR merges the ability to input multiple queries through the '-q' flag and file-based input ('-v' flag) for added flexibility. The enhanced output now includes the respective query for each matched line in the 'matched_line_dict,' providing crucial context.

 This PR merges the ability to input multiple queries through the '-q' flag and file-based input ('-v' flag) for added flexibility. The enhanced output now includes the respective query for each matched line in the 'matched_line_dict,' providing crucial context.
@chrisdoman
Copy link
Contributor

Thank-you!

Looks like it causes some issues with JSON output based on the failing unit tests (below). I'll take a look this week if I have time.

python3 -m unittest discover ./tests

`======================================================================
ERROR: test_json_output (test_unit.CloudGrepTests.test_json_output)

Traceback (most recent call last):
File "/Users/chris/Developer/cloudgrep/tests/test_unit.py", line 160, in test_json_output
self.assertTrue(json.loads(output))
^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/init.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 340, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 154)

======================================================================
ERROR: test_search_cloudtrail (test_unit.CloudGrepTests.test_search_cloudtrail)

Traceback (most recent call last):
File "/Users/chris/Developer/cloudgrep/tests/test_unit.py", line 203, in test_search_cloudtrail
self.assertTrue(json.loads(output))
^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/init.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 340, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 1598)

======================================================================
FAIL: test_e2e (test_unit.CloudGrepTests.test_e2e)

Traceback (most recent call last):
File "/opt/homebrew/lib/python3.11/site-packages/timeout_decorator/timeout_decorator.py", line 82, in new_function
return function(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/moto/core/models.py", line 128, in wrapper
result = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/chris/Developer/cloudgrep/tests/test_unit.py", line 78, in test_e2e
assert hits == 1
^^^^^^^^^
AssertionError

======================================================================
FAIL: test_returns_string_with_file_contents (test_unit.CloudGrepTests.test_returns_string_with_file_contents)

Traceback (most recent call last):
File "/Users/chris/Developer/cloudgrep/tests/test_unit.py", line 126, in test_returns_string_with_file_contents
self.assertIsInstance(queries, str)
AssertionError: ['query1', 'query2', 'query3'] is not an instance of <class 'str'>
`

MelaElezaj and others added 2 commits January 8, 2024 17:09
@chrisdoman chrisdoman merged commit 2306ad3 into cado-security:main Jan 22, 2024
4 checks passed
@chrisdoman
Copy link
Contributor

Sorry for the delay and thanks for fixing the tests. Happy to be merging this now!

Thanks again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants