コード例 #1
0
async def test_build_from_snapshot():
    snapshot = make_snapshot()

    records = await DnsRecordFactory.from_snapshot(snapshot)
    for record in records:
        print(record.value)
    assert len(records) > 0
コード例 #2
0
def test_build_from_snapshot():
    snapshot = make_snapshot()

    classifications = ClassificationFactory.from_snapshot(snapshot)
    assert len(classifications) > 0

    first = classifications[0]
    assert not first.malicious
コード例 #3
0
ファイル: test_scripts.py プロジェクト: HackdYourShit/uzen
async def test_build_from_snapshot():
    snapshot = make_snapshot()
    snapshot.body = '<html><body><script type="text/javascript" src="https://www.w3.org/2008/site/js/main"></body></html>'
    respx.get("https://www.w3.org/2008/site/js/main", content="foo")

    scripts = await ScriptFactory.from_snapshot(snapshot)
    assert len(scripts) == 1

    script = scripts[0]
    assert script.url == "https://www.w3.org/2008/site/js/main"
    assert "foo" in script.content
コード例 #4
0
ファイル: test_scripts.py プロジェクト: Blue-infosec/uzen
def test_build_from_snapshot():
    snapshot = make_snapshot()
    snapshot.body = '<html><body><script type="text/javascript" src="https://www.w3.org/2008/site/js/main"></body></html>'

    scripts = ScriptBuilder.build_from_snapshot(snapshot)
    assert len(scripts) == 1

    script = scripts[0]
    assert script.url == "https://www.w3.org/2008/site/js/main"
    assert (
        "/*! See W3C-specific code uncompressed at http://www.w3.org/2008/site/js/core.js */"
        in script.content)
コード例 #5
0
ファイル: test_scripts.py プロジェクト: killvxk/uzen
async def test_build_from_snapshot_with_relative_src():
    snapshot = make_snapshot()
    snapshot.url = "https://www.w3.org"
    snapshot.body = '<html><body><script type="text/javascript" src="/2008/site/js/main"></body></html>'
    respx.get("https://www.w3.org/2008/site/js/main").mock(
        Response(status_code=200, content="foo"))

    scripts = await ScriptFactory.from_snapshot(snapshot)
    assert len(scripts) == 1

    script = scripts[0]
    assert script.url == "https://www.w3.org/2008/site/js/main"
    assert "foo" in script.content
コード例 #6
0
ファイル: test_scripts.py プロジェクト: HackdYourShit/uzen
async def test_build_from_snapshot_with_no_src():
    snapshot = make_snapshot()
    snapshot.body = '<html><body><script type="text/javascript"></body></html>'

    scripts = await ScriptFactory.from_snapshot(snapshot)
    assert len(scripts) == 0
コード例 #7
0
ファイル: test_scripts.py プロジェクト: Blue-infosec/uzen
def test_build_from_snapshot_with_no_src():
    snapshot = make_snapshot()
    snapshot.body = '<html><body><script type="text/javascript"></body></html>'

    scripts = ScriptBuilder.build_from_snapshot(snapshot)
    assert len(scripts) == 0
コード例 #8
0
def snapshot_for_test() -> Snapshot:
    snapshot = make_snapshot()
    snapshot.scripts = [Script(content="foo"), Script(content="bar")]
    return snapshot
コード例 #9
0
def mock_import_as_snapshot(url: str):
    return make_snapshot()
コード例 #10
0
def mock_take_snapshot(
    url: str, user_agent: None, timeout: None, ignore_https_errors: False
):
    return make_snapshot()