Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Marven11 committed Jul 26, 2023
1 parent f61ba20 commit 0b1345e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
4 changes: 2 additions & 2 deletions tests/test_cracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

import unittest
import fenjing
from flask import render_template_string
from typing import Union
from fenjing.cracker import Cracker
from fenjing.submitter import BaseSubmitter, HTTPResponse
from fenjing import const
import jinja2
import logging


Expand All @@ -24,7 +24,7 @@ def submit_raw(self, raw_payload: str) -> Union[HTTPResponse, None]:
if not self.waf(raw_payload):
return HTTPResponse(200, "Nope")
try:
result = jinja2.Template(source=raw_payload).render()
result = render_template_string(raw_payload)
return HTTPResponse(200, result)
except Exception:
return HTTPResponse(500, "Internal Server Error")
Expand Down
20 changes: 11 additions & 9 deletions tests/test_full_payload_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

import fenjing
import logging
from flask import render_template_string


from fenjing import FullPayloadGen, const
import unittest
import jinja2
import random

fenjing.full_payload_gen.logger.setLevel(logging.ERROR)
Expand Down Expand Up @@ -45,7 +47,7 @@ def test_string(self):
assert payload is not None
# why?
# cause the stupid type checker thinks the 'payload' below would still be None
result = jinja2.Template(payload).render()
result = render_template_string(payload)
self.assertIn(string, result)
for word in self.blacklist:
self.assertNotIn(word, payload)
Expand All @@ -58,7 +60,7 @@ def test_os_popen_read(self):
assert payload is not None
# why?
# cause the stupid type checker thinks the 'payload' below would still be None
result = jinja2.Template(payload).render()
result = render_template_string(payload)
self.assertIn("fen jing", result)
for word in self.blacklist:
self.assertNotIn(word, payload)
Expand Down Expand Up @@ -121,7 +123,7 @@ def test_string(self):
assert payload is not None
# why?
# cause the stupid type checker thinks the 'payload' below would still be None
result = jinja2.Template(payload).render()
result = render_template_string(payload)
self.assertIn(string, result)
for word in self.blacklist:
self.assertNotIn(word, payload)
Expand All @@ -134,7 +136,7 @@ def test_os_popen_read(self):
assert payload is not None
# why?
# cause the stupid type checker thinks the 'payload' below would still be None
result = jinja2.Template(payload).render()
result = render_template_string(payload)
self.assertIn("fen jing", result)
for word in self.blacklist:
self.assertNotIn(word, payload)
Expand Down Expand Up @@ -196,7 +198,7 @@ def test_string(self):
assert payload is not None
# why?
# cause the stupid type checker thinks the 'payload' below would still be None
result = jinja2.Template(payload).render()
result = render_template_string(payload)
self.assertIn(string, result)
for word in self.blacklist:
self.assertNotIn(word, payload)
Expand All @@ -209,7 +211,7 @@ def test_os_popen_read(self):
assert payload is not None
# why?
# cause the stupid type checker thinks the 'payload' below would still be None
result = jinja2.Template(payload).render()
result = render_template_string(payload)
self.assertIn("fen jing", result)

for word in self.blacklist:
Expand Down Expand Up @@ -291,7 +293,7 @@ def test_string(self):
assert payload is not None
# why?
# cause the stupid type checker thinks the 'payload' below would still be None
result = jinja2.Template(payload).render()
result = render_template_string(payload)
self.assertIn(string, result)
for word in blacklist:
self.assertNotIn(word, payload)
Expand All @@ -303,7 +305,7 @@ def test_os_popen_read(self):
assert payload is not None
# why?
# cause the stupid type checker thinks the 'payload' below would still be None
result = jinja2.Template(payload).render()
result = render_template_string(payload)
self.assertIn("fen jing", result)
for word in blacklist:
self.assertNotIn(word, payload)
3 changes: 3 additions & 0 deletions tests/test_payload_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

import unittest
import fenjing
from flask import render_template_string


from fenjing.payload_gen import PayloadGenerator
from fenjing import const
import logging
Expand Down

0 comments on commit 0b1345e

Please sign in to comment.