Skip to content

Commit

Permalink
diff cache key for get and post vars
Browse files Browse the repository at this point in the history
  • Loading branch information
xmendez committed Dec 28, 2018
1 parent cb715db commit cd927ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/wfuzz/fuzzobjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ def update_from_raw_http(self, raw, scheme, raw_response=None):
def to_cache_key(self):
key = self._request.urlWithoutVariables

dicc = {key: True for key in self.params.get.keys()}
dicc.update({key: True for key in self.params.post.keys()})
dicc = {f'g{key}': True for key in self.params.get.keys()}
dicc.update({f'p{key}': True for key in self.params.post.keys()})

# take URL parameters into consideration
url_params = list(dicc.keys())
Expand Down
16 changes: 10 additions & 6 deletions tests/test_reqresp.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,37 +132,41 @@ def test_allvars(self):

def test_cache_key(self):
fr = FuzzRequest()
fr.url = "http://www.wfuzz.org/"
self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-')

fr = FuzzRequest()
fr.url = "http://www.wfuzz.org/"
fr.params.get = {'a': '1', 'b': '2'}
self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-a-b')
self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-ga-gb')

fr = FuzzRequest()
fr.url = "http://www.wfuzz.org/"
fr.params.post = {'c': '1', 'd': '2'}
self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-c-d')
self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-pc-pd')

fr = FuzzRequest()
fr.url = "http://www.wfuzz.org/"
fr.params.get = {'a': '1', 'b': '2'}
fr.params.post = {'c': '1', 'd': '2'}
self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-a-b-c-d')
self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-ga-gb-pc-pd')

fr = FuzzRequest()
fr.url = "http://www.wfuzz.org/"
fr.params.get = {'a': '1', 'b': '2'}
fr.params.post = {'a': '1', 'b': '2'}
self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-a-b')
self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-ga-gb-pa-pb')

fr = FuzzRequest()
fr.url = "http://www.wfuzz.org/"
fr.params.post = '1'
self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-1')
self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-p1')

fr = FuzzRequest()
fr.url = "http://www.wfuzz.org/"
fr.params.post = ''
self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-')
self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-p')


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

0 comments on commit cd927ed

Please sign in to comment.