mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Python: Extract files in hidden dirs by default
Changes the default behaviour of the Python extractor so files inside hidden directories are extracted by default. Also adds an extractor option, `skip_hidden_directories`, which can be set to `true` in order to revert to the old behaviour. Finally, I made the logic surrounding what is logged in various cases a bit more obvious. Technically this changes the behaviour of the extractor (in that hidden excluded files will now be logged as `(excluded)`, but I think this makes more sense anyway.
This commit is contained in:
@@ -44,3 +44,10 @@ options:
|
||||
Use this setting with caution, the Python extractor requires Python 3 to run.
|
||||
type: string
|
||||
pattern: "^(py|python|python3)$"
|
||||
skip_hidden_directories:
|
||||
title: Controls whether hidden directories are skipped during extraction.
|
||||
description: >
|
||||
By default, CodeQL will extract all Python files, including ones located in hidden directories. By setting this option to true, these hidden directories will be skipped instead.
|
||||
Accepted values are true and false.
|
||||
type: string
|
||||
pattern: "^(true|false)$"
|
||||
|
||||
@@ -83,11 +83,10 @@ class Traverser(object):
|
||||
self.logger.debug("Ignoring %s (symlink)", fullpath)
|
||||
continue
|
||||
if isdir(fullpath):
|
||||
if fullpath in self.exclude_paths or is_hidden(fullpath):
|
||||
if is_hidden(fullpath):
|
||||
self.logger.debug("Ignoring %s (hidden)", fullpath)
|
||||
else:
|
||||
self.logger.debug("Ignoring %s (excluded)", fullpath)
|
||||
if fullpath in self.exclude_paths:
|
||||
self.logger.debug("Ignoring %s (excluded)", fullpath)
|
||||
elif is_hidden(fullpath):
|
||||
self.logger.debug("Ignoring %s (hidden)", fullpath)
|
||||
else:
|
||||
empty = True
|
||||
for item in self._treewalk(fullpath):
|
||||
@@ -101,7 +100,12 @@ class Traverser(object):
|
||||
self.logger.debug("Ignoring %s (filter)", fullpath)
|
||||
|
||||
|
||||
if os.name== 'nt':
|
||||
if os.environ.get("CODEQL_EXTRACTOR_PYTHON_OPTION_SKIP_HIDDEN_DIRECTORIES", "false") == "false":
|
||||
|
||||
def is_hidden(path):
|
||||
return False
|
||||
|
||||
elif os.name== 'nt':
|
||||
import ctypes
|
||||
|
||||
def is_hidden(path):
|
||||
|
||||
Reference in New Issue
Block a user