Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f777067

Browse files
authored
Merge pull request #18 from luminougat/fix-fuzzing-with-parameters-2
Fix fuzzing with parameters in case of lists (Part 2)
2 parents 1061a91 + 04eef8c commit f777067

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ __pycache__
33
*.egg-info/
44
build/
55
dist/
6+
*.pyc

pyjfuzz/core/pjf_factory.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ def fuzz_elements(self, element):
160160
elif type(key) == list:
161161
arr.append(self.fuzz_elements(key))
162162
else:
163-
arr.append(self.mutator.fuzz(key))
163+
if len(self.config.parameters) <= 0:
164+
arr.append(self.mutator.fuzz(key))
165+
else:
166+
arr.append(key)
164167
element = arr
165168
del arr
166169
except Exception as e:

test/test_pjf_factory.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ def test_object_fuzz(self):
7171
indent=True, nologo=True)))
7272
self.assertTrue(json.fuzzed)
7373

74+
def test_object_parameters(self):
75+
json = PJFFactory(PJFConfiguration(Namespace(parameters="d", json={"a": [{"b" : "c"}, "abcd"]}, nologo=True, level=6)))
76+
self.assertTrue(json != json.fuzzed)
77+
self.assertTrue("abcd" in json.fuzzed)
78+
79+
7480

7581
def test():
7682
print("=" * len(__TITLE__))

0 commit comments

Comments
 (0)