Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
superstes committed Oct 18, 2024
1 parent fa56947 commit ed914c7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
1 change: 1 addition & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
- name: Install dependencies
run: |
pip install -r requirements_lint.txt
pip install -r src/requirements.txt
sudo apt install shellcheck
shell: bash

Expand Down
10 changes: 6 additions & 4 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ exclude-too-few-public-methods=
ignored-parents=

# Maximum number of arguments for function / method.
max-args=5
max-args=6

# Maximum number of attributes for a class (see R0902).
max-attributes=7
Expand All @@ -302,13 +302,13 @@ max-bool-expr=5
max-branches=12

# Maximum number of locals for function / method body.
max-locals=15
max-locals=16

# Maximum number of parents for a class (see R0901).
max-parents=7

# Maximum number of positional arguments for function / method.
max-positional-arguments=5
max-positional-arguments=6

# Maximum number of public methods for a class (see R0904).
max-public-methods=20
Expand Down Expand Up @@ -345,7 +345,7 @@ indent-after-paren=4
indent-string=' '

# Maximum number of characters on a single line.
max-line-length=120
max-line-length=130

# Maximum number of lines in a module.
max-module-lines=1000
Expand Down Expand Up @@ -440,6 +440,8 @@ disable=raw-checker-failed,
use-implicit-booleaness-not-comparison-to-string,
use-implicit-booleaness-not-comparison-to-zero,
C0114, C0115, C0116, # inline docs
W0401, W0614, # wildcard import for config
W0511, # todos

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
8 changes: 4 additions & 4 deletions src/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,16 @@ def build_dbs_ip_asn(reports: dict, ptrs: dict, lookup_lists: dict, networks: di
asn_reports[asn]['reports'][report_type] += report_count

# todo: score relative by IP and separate ip4/6
for asn in asn_reports:
for av in asn_reports.values():
rel_by_ip4 = round(
asn_reports[asn]['reports']['all'] / (asn_reports[asn]['info']['ipv4'] + 1),
av['reports']['all'] / (av['info']['ipv4'] + 1),
5
)
if str(rel_by_ip4).find('-') != -1:
asn_reports[asn]['reports']['rel_by_ip4'] = 0.0
av['reports']['rel_by_ip4'] = 0.0

else:
asn_reports[asn]['reports']['rel_by_ip4'] = rel_by_ip4
av['reports']['rel_by_ip4'] = rel_by_ip4

write_ip_asn(
key=key,
Expand Down
11 changes: 6 additions & 5 deletions src/reputation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from config import *

# pylint: disable=W0613
def _reporter_reputation(r: dict) -> int:
reputation = 0

Expand Down Expand Up @@ -97,15 +98,15 @@ def reports_by_network_reputation(reports: list[dict]) -> dict:
for k in [reported_nets_all, reported_nets_med, reported_nets_high]:
for n, nv in k.items():
ip_cnt = len(nv['ips'])
k[n]['reported_ips'] = ip_cnt
k[n][rep_key] = 'ok'
nv['reported_ips'] = ip_cnt
nv[rep_key] = 'ok'

for rep, cnt in NETWORK_REPUTATION_IPS[k[n]['ipv']].items():
for rep, cnt in NETWORK_REPUTATION_IPS[nv['ipv']].items():
if ip_cnt >= cnt:
k[n][rep_key] = rep
nv[rep_key] = rep
break

k[n].pop('ips')
nv.pop('ips')

return {
'all': reported_nets_all,
Expand Down

0 comments on commit ed914c7

Please sign in to comment.