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

Changing the logic in the requests configuration #600

Merged
merged 6 commits into from
Nov 20, 2023

Conversation

anna1492
Copy link
Contributor

No description provided.

@anna1492 anna1492 marked this pull request as ready for review October 31, 2023 10:42
@@ -129,12 +129,12 @@ class Limits:
"E.g. when set to 100, Artemis will send no more than 100 port scanning packets per seconds per port scanner instance.",
] = get_config("SCANNING_PACKETS_PER_SECOND", default=100, cast=int)

SECONDS_PER_REQUEST: Annotated[
REQUEST_PER_SECOND: Annotated[
Copy link
Member

@kazet kazet Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REQUESTS_PER_SECOND

int,
"""
E.g. when set to 2, Artemis will make sure no HTTP/MySQL connect/... request takes less than 2 seconds, sleeping if needed.
E.g. when set to 2, Artemis will make sure no more HTTP/MySQL connect/... requests take place per second, sleeping if needed.
Copy link
Member

@kazet kazet Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no more than 2 ...

artemis/utils.py Outdated
if func_time < average_time_per_request:
time.sleep(average_time_per_request - func_time)
elif request_per_second < 1:
seconds_for_req = math.floor(1 / request_per_second)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

czemu floor? jak ma byc 0.75 requesta per second to sleep 1/0.75 i zalatwione

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming int, now is float - so it can be that way.

str(int(Config.Limits.SECONDS_PER_REQUEST * 1000.0 / len(tasks_filtered))),
str(int((1 / Config.Limits.REQUEST_PER_SECOND) * 1000.0 / len(tasks_filtered)))
if Config.Limits.REQUEST_PER_SECOND != 0
else str(int(0)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why int(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the value here, not the structure. It was earlier here, and I assumed it had its purpose. But if you change the structure, it won't work (nuclei takes int), and tests will (obviously) not pass in one of our config conditions. So - do you propose something specific here, or you just asked?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant that 'else str(int(0))' can be reduced to 'else str(0)'

if time_elapsed < Config.Limits.SECONDS_PER_REQUEST:
time.sleep(Config.Limits.SECONDS_PER_REQUEST - time_elapsed)
elif request_per_second >= 1:
average_time_per_request = 1 / request_per_second
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now you have two duplicate if branches

@anna1492 anna1492 merged commit 8bff016 into main Nov 20, 2023
@anna1492 anna1492 deleted the changing-the-logic-in-the-requests-configuration branch November 20, 2023 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants