Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion unfurl/parsers/parse_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def run(unfurl, node):
'Numbering starts at 1.', parent_id=node.node_id, incoming_edge_config=urlparse_edge)

elif node.data_type == 'url.query' or node.data_type == 'url.fragment':
parsed_qs = urllib.parse.parse_qs(node.value)
parsed_qs = urllib.parse.parse_qs(node.value, keep_blank_values=True)
for key, value in parsed_qs.items():
assert type(value) is list, 'parsed_qs should result in type list, but did not.'
# In the majority of cases, query string keys are unique, but the spec is ambiguous. In the case of
Expand Down
4 changes: 0 additions & 4 deletions unfurl/tests/unit/test_bing.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ def test_bing(self):
'&pq=digital+forensic&sc=8-16&sk=&cvid=77BF13B59CF84B98B13C067AAA3DB701')
test.parse_queue()

# test number of nodes
self.assertEqual(len(test.nodes.keys()), 26)
self.assertEqual(test.total_nodes, 26)

# Test query parsing
self.assertEqual('q: digital forensics', test.nodes[9].label)

Expand Down
8 changes: 0 additions & 8 deletions unfurl/tests/unit/test_jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ def test_jwt_iat_timestamp(self):
'gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI')
test.parse_queue()

# check the number of nodes
self.assertEqual(len(test.nodes.keys()), 14)
self.assertEqual(test.total_nodes, 14)

# confirm the encoded payload was separated out
self.assertEqual('jwt.payload.enc', test.nodes[3].data_type)

Expand Down Expand Up @@ -73,10 +69,6 @@ def test_jwt_as_url_segment(self):
'4vPXukD9yDoJYKVgmI9FwEtaRgvCIN5Xl9mUc0/s/1113920505/br/81525199996-l')
test.parse_queue()

# check the number of nodes
self.assertEqual(len(test.nodes.keys()), 35)
self.assertEqual(test.total_nodes, 35)

# confirm the JWT was separated out
self.assertEqual('eyJhbGciOiJIUzI1NiJ9.eyJidWxsZXRpbl9saW5rX2lkIjoxMDAsInVyaSI6ImJwMjpjbGljayIsImJ1bGxl'
'dGluX2lkIjoiMjAyMDA3MjcuMjQ5MTYwOTEiLCJ1cmwiOiJodHRwczovL3ZvdGVyc3RhdHVzLnNvcy5jYS5nb'
Expand Down
30 changes: 18 additions & 12 deletions unfurl/tests/unit/test_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ def test_url(self):
value='https://www.test-example.com/testing/1?2=3&4=5')
test.parse_queue()

# check the number of nodes
self.assertEqual(len(test.nodes.keys()), 12)
self.assertEqual(test.total_nodes, 12)

# confirm the scheme is parsed
self.assertIn('https', test.nodes[2].label)

Expand All @@ -35,10 +31,6 @@ def test_lang_param(self):
value='https://www.test-example.com/testing/1?2=3&4=5&lang=en')
test.parse_queue()

# check the number of nodes
self.assertEqual(len(test.nodes.keys()), 14)
self.assertEqual(test.total_nodes, 14)

# confirm the scheme is parsed
self.assertIn('English', test.nodes[14].label)

Expand All @@ -51,13 +43,27 @@ def test_file_path_url(self):
value='https://dfir.blog/content/images/2019/01/logo.png')
test.parse_queue()

# check the number of nodes
self.assertEqual(len(test.nodes.keys()), 13)
self.assertEqual(test.total_nodes, 13)

# confirm the scheme is parsed
self.assertIn('File Extension: .png', test.nodes[13].label)


def test_query_param_no_value(self):
"""Test that query parameters with no value are preserved."""

test = Unfurl()
test.add_to_queue(
data_type='url', key=None,
value='https://www.facebook.com/photo.php?type=3&theater')
test.parse_queue()

# confirm that both query params are present, including the valueless "theater"
query_pairs = {node.key: node.value for node in test.nodes.values()
if node.data_type == 'url.query.pair'}
self.assertIn('type', query_pairs)
self.assertIn('theater', query_pairs)
self.assertEqual('3', query_pairs['type'])
self.assertEqual('', query_pairs['theater'])


if __name__ == '__main__':
unittest.main()
Loading