Skip to content

Commit

Permalink
Merge 62b8b4e into fc1d1ab
Browse files Browse the repository at this point in the history
  • Loading branch information
Sree Siva Sandeep Palaparthi committed Nov 11, 2019
2 parents fc1d1ab + 62b8b4e commit 44740eb
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pastepwn/analyzers/pastebinurlanalyzer.py
Expand Up @@ -7,5 +7,5 @@ class PastebinURLAnalyzer(URLAnalyzer):
name = "PastebinURLAnalyzer"

def __init__(self, actions, resolve=False):
regex = r"((?:https?:\/\/)?pastebin.com\/\S+)"
regex = r"((?:https?:\/\/)?pastebin.com\/[a-zA-Z0-9]{3,})"
super().__init__(actions, regex, resolve)
43 changes: 43 additions & 0 deletions pastepwn/analyzers/tests/pastebinurlanalyzer_test.py
@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
import unittest
from unittest import mock

from pastepwn.analyzers.pastebinurlanalyzer import PastebinURLAnalyzer


class TestPastebinURLAnalyzer(unittest.TestCase):
def setUp(self):
self.analyzer = PastebinURLAnalyzer(None)
self.paste = mock.Mock()

def test_match_positive(self):
self.paste.body = "https://pastebin.com/xyz"
self.assertTrue(self.analyzer.match(self.paste))
self.paste.body = "https://pastebin.com/xyz/"
self.assertTrue(self.analyzer.match(self.paste))
self.paste.body = "http://pastebin.com/xyz"
self.assertTrue(self.analyzer.match(self.paste))
self.paste.body = "http://pastebin.com/xyz/"
self.assertTrue(self.analyzer.match(self.paste))
self.paste.body = "https://pastebin.com/xyz "
self.assertTrue(self.analyzer.match(self.paste))
self.paste.body = "www.pastebin.com/xyz"
self.assertTrue(self.analyzer.match(self.paste))
self.paste.body = "pastebin.com/xyx"
self.assertTrue(self.analyzer.match(self.paste))
self.paste.body = "This is a pastebin URL: pastebin.com/ya249asd - and this is a test"

def test_match_negative(self):
self.paste.body = ""
self.assertFalse(self.analyzer.match(self.paste))
self.paste.body = None
self.assertFalse(self.analyzer.match(self.paste))
self.paste.body = "https://google.com/xyz"
self.assertFalse(self.analyzer.match(self.paste))
self.paste.body = "xyzpastebin.com/k"
self.assertFalse(self.analyzer.match(self.paste))
self.paste.body = "https://pastebin.com/"
self.assertFalse(self.analyzer.match(self.paste))

if __name__ == '__main__':
unittest.main()

0 comments on commit 44740eb

Please sign in to comment.