Skip to content

Commit

Permalink
Improve filtering out of false endpoints. (#49)
Browse files Browse the repository at this point in the history
Signed-off-by: Caroline Russell <caroline@appthreat.dev>
  • Loading branch information
cerrussell authored Apr 12, 2024
1 parent 073a81f commit c9c6a5a
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 193 deletions.
2 changes: 1 addition & 1 deletion atom_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
A cli, classes and functions for converting an atom slice to a different format
"""
__version__ = '0.5.4'
__version__ = '0.5.5'
9 changes: 6 additions & 3 deletions atom_tools/lib/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@

logger = logging.getLogger(__name__)
regex = OpenAPIRegexCollection()

exclusions = ['/content-type', '/application/javascript', '/application/json', '/application/text',
'/application/xml', '/*', '/*/*', '/allow', '/GET', '/POST', '/xml', '/cookie']
'/application/xml', '/*', '/*/*', '/allow', '/get', '/post', '/xml', '/cookie',
'/usestrict', '/maxage', '/sessionid']


class OpenAPI:
Expand Down Expand Up @@ -256,7 +258,7 @@ def _extract_endpoints(self, method: str) -> List[str]:
matches = self._filter_matches(matches, method)
return [
v for v in matches
if v and v not in exclusions and not v.lower().startswith('/x-')
if v and v.lower() not in exclusions and not v.lower().startswith('/x-')
]

def _extract_params(self, ep: str) -> Tuple[str, bool, List]:
Expand Down Expand Up @@ -298,7 +300,8 @@ def _filter_matches(self, matches: List[str], code: str) -> List[str]:
):
return filtered_matches
case 'js' | 'ts' | 'javascript' | 'typescript':
if 'app.' not in code and 'route' not in code and 'ftp' not in code:
if ('app.' not in code and 'route' not in code and 'ftp' not in code) or (
'app.set(' in code):
return filtered_matches

for m in matches:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "atom-tools"
version = "0.5.4"
version = "0.5.5"
description = "Collection of tools for use with AppThreat/atom."
authors = [
{ name = "Caroline Russell", email = "caroline@appthreat.dev" },
Expand Down
Loading

0 comments on commit c9c6a5a

Please sign in to comment.