Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bup): add proxy option and progress indicator #444

Merged
merged 2 commits into from
Sep 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions secator/tasks/bup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import json
import re

from secator.decorators import task
from secator.output_types import Url
from secator.output_types import Url, Progress
from secator.tasks._categories import Http
from secator.definitions import (
HEADER, DELAY, FOLLOW_REDIRECT, METHOD, PROXY, RATE_LIMIT, RETRIES, THREADS, TIMEOUT, USER_AGENT,
Expand Down Expand Up @@ -42,9 +43,9 @@ class bup(Http):
FILTER_WORDS: OPT_NOT_SUPPORTED,
FOLLOW_REDIRECT: OPT_NOT_SUPPORTED,
MATCH_CODES: OPT_NOT_SUPPORTED,
PROXY: OPT_NOT_SUPPORTED,
PROXY: 'proxy',
}
output_types = [Url]
output_types = [Url, Progress]
output_map = {
Url: {
'url': 'request_url',
Expand All @@ -66,6 +67,14 @@ class bup(Http):
def on_init(self):
self.cmd += f' -o {self.reports_folder}/.outputs/response'

@staticmethod
def on_line(self, line):
if 'Doing' in line:
progress_indicator = line.split(':')[-1]
current, total = tuple([int(c.strip()) for c in progress_indicator.split('/')])
return json.dumps({"duration": "unknown", "percent": int((current / total) * 100)})
return line

@staticmethod
def method_extractor(item):
payload = item['request_curl_payload']
Expand Down
Loading