connectors icon indicating copy to clipboard operation
connectors copied to clipboard

[external-import] Break loop if run and terminate is enabled

Open rlynch-ironnet opened this issue 2 years ago • 3 comments

Proposed changes

  • Connectors should obey the CONNECTOR_RUN_AND_TERMINATE option if possible. Run once, then die without looping infinitely.
  • At some point I'll have to rework the listener queue to enable this for the internal connector types, I'd like them to die if the queue is empty. Spin up a task every N minutes, check for messages, die once complete.

Related issues

  • None

Checklist

  • [x] I consider the submitted work as finished
  • ❌ ~~I tested the code for its functionality using different use cases~~
    • Half of these require creds to test, however the changes are small and the config option is guaranteed to exist in the helper.
  • [x] I added/update the relevant documentation (either on github or on notion)
  • [x] Where necessary I refactored code to improve the overall quality

Further comments

  • 👍

rlynch-ironnet avatar Jul 18 '22 14:07 rlynch-ironnet

From what stackoverflow was explaining, theyre effectively the same. but better to not need more pylint exceptions.

On Wed, Jul 20, 2022 at 1:54 AM Axel Fahy @.***> wrote:

@.**** commented on this pull request.

In external-import/alienvault/src/alienvault/core.py https://github.com/OpenCTI-Platform/connectors/pull/762#discussion_r925200123 :

         except (KeyboardInterrupt, SystemExit):
             self._info("Connector stop")
             exit(0)
  •        if self.helper.connect_run_and_terminate:
    
  •            self.helper.log_info("Connector stop")
    
  •            exit(0)
    

According to pylint (R1722: Consider using sys.exit() (consider-using-sys-exit)), it's cleaner to use sys.exit(0). I am not sure if there was a specific reason to use exit(0) instead.

— Reply to this email directly, view it on GitHub https://github.com/OpenCTI-Platform/connectors/pull/762#discussion_r925200123, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJKJEYRVXCT5HJS3FY5QT5TVU6ICZANCNFSM534Q5NPA . You are receiving this because you authored the thread.Message ID: @.***>

--

This message is intended exclusively for the individual(s) or entity to which it is addressed. It may contain information that is privileged or otherwise legally exempt from disclosure.  If you are not the named addressee, you are not authorized to read, print, retain, copy or disseminate this message or any part of it. If you have received this message in error, please notify the sender immediately by e-mail and delete all copies of the message.

Any digital signatures or certifications transmitted with this email are for sender verification purposes only and have not been included in this email for the purposes of binding the company to any statement or attachment made herein or for any other purpose.

rlynch-ironnet avatar Jul 20 '22 12:07 rlynch-ironnet

Merging #763 into this so CI passes.

rlynch-ironnet avatar Jul 20 '22 13:07 rlynch-ironnet

  • Switched to sys.exit
  • Added import sys where necessary
  • Committed any isort changes

rlynch-ironnet avatar Jul 20 '22 13:07 rlynch-ironnet