Skip to content

Commit

Permalink
Merge branch 'fixes/snippets' into alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
megalinter-bot committed Jul 15, 2023
2 parents ef4b12e + 04d747c commit f9b7b29
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions server/docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ services:
# command: rq worker --url redis://megalinter_server_redis:6379 megalinter:queue:requests
command: rq worker-pool --num-workers 5 --url redis://megalinter_server_redis:6379 megalinter:queue:requests # Uncomment to try worker pool
environment:
# Megalinter variables
- FLAVOR_SUGGESTIONS=false
# Worker variables
- MEGALINTER_SERVER=true
- LOG_LEVEL=DEBUG # Much more logs including run commands
Expand Down
2 changes: 2 additions & 0 deletions server/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ services:
image: ghcr.io/oxsecurity/megalinter-security:alpha # cupcake is more complete
#image: ghcr.io/oxsecurity/megalinter:alpha # all linters
environment:
# Megalinter variables
- FLAVOR_SUGGESTIONS=false
# Worker variables
- MEGALINTER_SERVER=true
- MEGALINTER_SERVER_REDIS_HOST=megalinter_server_redis
Expand Down
14 changes: 7 additions & 7 deletions server/server_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def initialize(self, request_input: AnalysisRequestInput, request_id, server_id)
self.request_input = request_input
if request_input.webHookUrl:
self.web_hook_url = request_input.webHookUrl
print(f"Analysis request {self.id} has been initialized")
logger.info(f"Analysis request {self.id} has been initialized")

# Initialize files for analysis
def initialize_files(self):
Expand Down Expand Up @@ -88,7 +88,7 @@ def init_from_repository(self):
)
err.send_redis_message()
raise err
print(f"Cloned {self.request_input.repositoryUrl} in temp dir {temp_dir}")
logger.info(f"Cloned {self.request_input.repositoryUrl} in temp dir {temp_dir}")
self.workspace = temp_dir
self.repository = self.request_input.repositoryUrl

Expand All @@ -105,7 +105,7 @@ def init_from_file_upload(self, file_upload_id):
else:
# No zip file
shutil.copytree(upload_dir, temp_dir, dirs_exist_ok=True)
print(f"Copied uploaded files from {self.id} in temp dir {temp_dir}")
logger.info(f"Copied uploaded files from {self.id} in temp dir {temp_dir}")
self.workspace = temp_dir
self.repository = self.request_input.repositoryUrl
else:
Expand All @@ -120,7 +120,7 @@ def init_from_file_upload(self, file_upload_id):

# Init from user snippet
def init_from_snippet(self):
print(f"Input snippet:\n {self.request_input.snippet}")
logger.info(f"Input snippet:\n {self.request_input.snippet}")
# Guess language using pygments
code_lexer = lexers.guess_lexer(self.request_input.snippet)
if not code_lexer:
Expand All @@ -133,7 +133,7 @@ def init_from_snippet(self):
err.send_redis_message()
raise err
self.snippet_language = code_lexer.name
print(f"Guessed snipped language: {self.snippet_language}")
logger.info(f"Guessed snipped language: {self.snippet_language}")
# Build file name
if len(code_lexer.filenames) > 0:
if "*." in code_lexer.filenames[0]:
Expand All @@ -149,7 +149,7 @@ def init_from_snippet(self):
)
err.send_redis_message()
raise err
print(f"Snippet file name: {snippet_file_name}")
logger.info(f"Snippet file name: {snippet_file_name}")
temp_dir = self.create_temp_dir()
snippet_file = os.path.join(temp_dir, snippet_file_name)
with open(snippet_file, "w", encoding="utf-8") as file:
Expand Down Expand Up @@ -188,4 +188,4 @@ def change_status(self, status: AnalysisStatus):
self.save()

def save(self):
print("Saved state " + str(self.__dict__))
logger.debug("Saved state " + str(self.__dict__))

0 comments on commit f9b7b29

Please sign in to comment.