Skip to content

Commit 6f35757

Browse files
committed
if stdin is provided, ignore default_wordlist
1 parent 457d0fa commit 6f35757

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

lib/helpers/wordlist_helper.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,30 @@
1111

1212

1313
class WordList:
14+
def __init__(self):
15+
self.wordlist = []
16+
self.wordlist_types = []
17+
1418
def get_stdin_wordlist(self):
1519
return list(line for line in sys.stdin.read().splitlines()) \
1620
if not sys.stdin.isatty() else []
1721

1822
def get_wordlist(self, wordlist_files=None):
19-
wordlist = []
20-
wordlist_types = []
2123
stdin_words = self.get_stdin_wordlist()
24+
default_wordlist_file = DEFAULT_WORDLIST_FILE
2225
if stdin_words:
23-
wordlist_types.append('stdin')
24-
wordlist.extend(stdin_words)
25-
combined_files = wordlist_files or DEFAULT_WORDLIST_FILE
26+
self.set_words('stdin', stdin_words)
27+
default_wordlist_file = None
28+
29+
combined_files = wordlist_files or default_wordlist_file
2630
combined = get_combined_word_lists(combined_files)
2731
if combined:
28-
wordlist_types.append('wordlists: {}'.format(
29-
', '.join(combined['file_paths'])))
30-
wordlist.extend(combined['words'])
31-
return wordlist, wordlist_types
32+
words_type = 'wordlists: {}'.format(
33+
', '.join(combined['file_paths']))
34+
self.set_words(words_type, combined['words'])
35+
36+
return self.wordlist, self.wordlist_types
37+
38+
def set_words(self, words_type, words):
39+
self.wordlist_types.append(words_type)
40+
self.wordlist.extend(words)

tests/helpers/test_wordlist_helper.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ def test_get_wordlist_from_stdin(self):
1515
stdin_wordlist = ['keyword1', 'keyword1']
1616
expected_wordlist = []
1717
expected_wordlist.extend(stdin_wordlist)
18-
expected_wordlist.extend(self.default_wordlist)
1918
with patch('lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
2019
wordlist, wordlist_types = self.wordlist.get_wordlist()
2120
self.assertEqual(wordlist, expected_wordlist)

0 commit comments

Comments
 (0)