Skip to content

Commit

Permalink
style!: Rename greylist_scan to in_greylist
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-d-zhang committed Jul 16, 2023
1 parent 2010db2 commit 0294f01
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/mainframe/endpoints/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from mainframe.constants import mainframe_settings
from mainframe.database import get_db
from mainframe.dependencies import get_ms_graph_client, validate_token
from mainframe.greylist import greylist_scan
from mainframe.greylist import in_greylist
from mainframe.json_web_token import AuthenticationData
from mainframe.models.orm import Scan
from mainframe.models.schemas import Error, PackageSpecifier
Expand Down Expand Up @@ -203,7 +203,7 @@ async def report_package(

rules_matched.extend(rule.name for rule in row.rules)

if greylist_scan(name, row.rule_names, session):
if in_greylist(name, row.rule_names, session):
raise HTTPException(
409,
detail=(
Expand Down
8 changes: 6 additions & 2 deletions src/mainframe/greylist.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@
from mainframe.models.orm import Scan, Status


async def greylist_scan(
async def in_greylist(
package_name: str,
rules_matched: list[str],
session: Annotated[AsyncSession, Depends(get_db)],
) -> bool:
"""Check if the rules we matched are the same as the last scan."""
"""
Check if the rules we matched are the same as the last scan.
If this package is the first release we scanned, returns `False`.
"""

if len(rules_matched) == 0:
return False
Expand Down

0 comments on commit 0294f01

Please sign in to comment.