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

Добавлена возможность отрезать лишную часть пути у issues #30

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
| -c; --commit | Коммит в репозитории, по которому запускалось сканирование | Нет, по умолчанию master |
| -bt; --build-tool | Сборщик (--help для просмотра всех сборщиков) | Нет, по умолчанию maven |
| --stage | Стадия экземпляра (ST - System Test, UAT - User Acceptance Test, IAT - Integration Acceptance Test, STG - Stage, PROD - Production) | Нет |
| -pr; --path_replace | Строковое значение для удаления части пути из fileName в конечном json | Нет |

### Список поддерживаемых форматов
bandit, burp, checkov, gitleaks, gosec, horusec, mobsf, sarif, semgrep, spotbugs, trufflehog, cyclonedx
Expand Down
5 changes: 4 additions & 1 deletion hub/parsers/hub_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,14 @@ def __parse_location(self, finding: Finding):
if finding.file_key not in self.locations:
scanner_type = self.__get_scanner_type(finding)
if scanner_type == ScannerTypes.SAST.value:
file_name = finding.file_path or 'Unknown'
if self.args.path_replace:
file_name = file_name.replace(self.args.path_replace, '')
self.locations[finding.file_key] = LocationSast(
type=self.args.type,
id=finding.file_key if finding.file_key else 'Unknown',
sourceId=self.source.id,
fileName=finding.file_path if finding.file_path else 'Unknown'
fileName=file_name
)
elif scanner_type == ScannerTypes.DAST.value:
self.locations[finding.file_key] = LocationDast(
Expand Down
6 changes: 6 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ def _prepare_choice(choices):
help="Stage of instance",
required=False
)
parser.add_argument(
"-pr", "--path-replace",
type=str,
help="Specify the path to be cut from the results json (default: None)",
default=None
)

args = parser.parse_args()

Expand Down
1 change: 1 addition & 0 deletions tests/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ArgsBase:
name: str = 'hub-tool-converters'
url: str = 'https://github.com/Swordfish-Security/hub-tool-converters.git'
format: str | None = None
path_replace: str | None = None


class ArgsCodebase(ArgsBase):
Expand Down