1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
import pytest
import re
from queue import Queue
@pytest.mark.parametrize(
"example_full_fuzzres_content, expected_links",
[
# getting data-href for now (b'<link rel="manifest" data-href="/android-chrome-manifest.json">\n', [],),
(
b'<href="1.json"href="2.json">\n',
["http://www.wfuzz.org/1.json", "http://www.wfuzz.org/2.json"],
),
(
b'<link rel="manifest" href="/android-chrome-manifest.json">\n',
["http://www.wfuzz.org/android-chrome-manifest.json"],
),
(
b'<link rel="alternate" href="https://www.wfuzz.org/" hreflang="en-AE" />',
["https://www.wfuzz.org/"],
),
(b'<link rel="dns-prefetch" href="https://www.wfuzz.io">\n', [],),
(b'<script src="//js.wfuzz.org/sttc/main.93d0d236.js"></script>', [],),
],
indirect=["example_full_fuzzres_content"],
)
def test_parsed_links(example_full_fuzzres_content, get_plugin, expected_links):
links_plugin = get_plugin("links")[0]
links_plugin.results_queue = Queue()
links_plugin.base_fuzz_res = example_full_fuzzres_content
links_plugin.add_path = False
assert links_plugin.name == "links"
links_plugin.process(example_full_fuzzres_content)
results = []
while not links_plugin.results_queue.empty():
results.append(links_plugin.results_queue.get())
assert [
fzres._seed.history.url for fzres in results if fzres._seed
] == expected_links
@pytest.mark.parametrize(
"example_full_fuzzres_content, expected_links",
[
(
b'<link rel="dns-prefetch" href="https://www.wfuzz.io">\n',
["https://www.wfuzz.io/"],
),
(
b'<script src="//js.wfuzz.org/sttc/main.93d0d236.js"></script>',
["http://js.wfuzz.org/sttc/main.93d0d236.js"],
),
],
indirect=["example_full_fuzzres_content"],
)
def test_regex_option(example_full_fuzzres_content, get_plugin, expected_links):
links_plugin = get_plugin("links")[0]
links_plugin.results_queue = Queue()
links_plugin.base_fuzz_res = example_full_fuzzres_content
links_plugin.add_path = False
links_plugin.domain_regex = re.compile("wfuzz", re.MULTILINE | re.DOTALL)
assert links_plugin.name == "links"
links_plugin.process(example_full_fuzzres_content)
results = []
while not links_plugin.results_queue.empty():
results.append(links_plugin.results_queue.get())
assert [
fzres._seed.history.url for fzres in results if fzres._seed
] == expected_links
|