airbnb / binaryalert

BinaryAlert: Serverless, Real-time & Retroactive Malware Detection.
https://binaryalert.io
Apache License 2.0
1.4k stars 187 forks source link

bug with ssh git repo cloning #123

Closed twaldear closed 5 years ago

twaldear commented 6 years ago

Background

using ./manage.py clone_rules fails for ssh git urls with the following stack trace:

[1/1] Cloning git@git.[redacted]... /var/folders/2_/s6d7t49d2y79bvm0tzqb585m9b4smz/T/YaraRules.git
Traceback (most recent call last):
  File "./manage.py", line 681, in <module>
    main()
  File "./manage.py", line 677, in main
    manager.run(args.command)
  File "./manage.py", line 528, in run
    getattr(self, command)()  # Command validation already happened in the ArgumentParser.
  File "./manage.py", line 597, in clone_rules
    clone_rules.clone_remote_rules()
  File "/Users/[redacted]/dev/binary_alert_project/binaryalert/rules/clone_rules.py", line 87, in clone_remote_rules
    files_copied = _clone_repo(source['url'], source.get('include'), source.get('exclude'))
  File "/Users/[redacted]/dev/binary_alert_project/binaryalert/rules/clone_rules.py", line 58, in _clone_repo
    target_repo_root = os.path.join(RULES_DIR, url.split('//')[1])
IndexError: list index out of range

Desired Change

Add split logic for ssh urls which do not contain //

austinbyers commented 5 years ago

Closed via #124