Skip to content

Commit ccae838

Browse files
authored
Supports for excluding paths from checking (#200)
Signed-off-by: SeongjunJo <[email protected]>
1 parent 046a5cc commit ccae838

File tree

9 files changed

+1875
-8
lines changed

9 files changed

+1875
-8
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ lxml
44
virtualenv
55
pyyaml
66
lastversion
7-
fosslight_util>=1.4.40
7+
fosslight_util>=1.4.43
88
PyGithub
99
requirements-parser
1010
defusedxml

src/fosslight_dependency/_help.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
-m <package_manager>\t Enter the package manager.
3333
\t(npm, maven, gradle, pip, pub, cocoapods, android, swift, carthage, go, nuget, helm)
3434
-p <input_path>\t\t Enter the path where the script will be run.
35+
-e <exclude_path>\t\t Enter the path where the analysis will not be performed.
3536
-o <output_path>\t\t Output path
3637
\t\t\t\t\t(If you want to generate the specific file name, add the output path with file name.)
3738
-f <format>\t\t\t Output file format (excel, csv, opossum, yaml, spdx-tag, spdx-yaml, spdx-json, spdx-xml)

src/fosslight_dependency/run_dependency_scanner.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
_exclude_dir = ['node_moduels', 'venv']
3838

3939

40-
def find_package_manager(input_dir):
40+
def find_package_manager(input_dir, abs_path_to_exclude=[]):
4141
ret = True
4242
manifest_file_name = []
4343
for value in const.SUPPORT_PACKAE.values():
@@ -52,7 +52,14 @@ def find_package_manager(input_dir):
5252
continue
5353
if os.path.basename(parent) in _exclude_dir:
5454
continue
55+
if os.path.abspath(parent) in abs_path_to_exclude:
56+
continue
5557
for file in files:
58+
file_path = os.path.join(parent, file)
59+
file_abs_path = os.path.abspath(file_path)
60+
if any(os.path.commonpath([file_abs_path, exclude_path]) == exclude_path
61+
for exclude_path in abs_path_to_exclude):
62+
continue
5663
if file in manifest_file_name:
5764
found_manifest_file.append(file)
5865
if len(found_manifest_file) > 0:
@@ -83,8 +90,9 @@ def find_package_manager(input_dir):
8390
return ret, found_package_manager, input_dir
8491

8592

86-
def run_dependency_scanner(package_manager='', input_dir='', output_dir_file='', pip_activate_cmd='', pip_deactivate_cmd='',
87-
output_custom_dir='', app_name=const.default_app_name, github_token='', format='', direct=True):
93+
def run_dependency_scanner(package_manager='', input_dir='', output_dir_file='', pip_activate_cmd='',
94+
pip_deactivate_cmd='', output_custom_dir='', app_name=const.default_app_name,
95+
github_token='', format='', direct=True, path_to_exclude=[]):
8896
global logger
8997

9098
ret = True
@@ -117,7 +125,8 @@ def run_dependency_scanner(package_manager='', input_dir='', output_dir_file='',
117125
sys.exit(1)
118126

119127
logger, _result_log = init_log(os.path.join(output_path, "fosslight_log_dep_" + _start_time + ".txt"),
120-
True, logging.INFO, logging.DEBUG, _PKG_NAME)
128+
True, logging.INFO, logging.DEBUG, _PKG_NAME, "", path_to_exclude)
129+
abs_path_to_exclude = [os.path.abspath(os.path.join(input_dir, path)) for path in path_to_exclude]
121130

122131
logger.info(f"Tool Info : {_result_log['Tool Info']}")
123132

@@ -151,7 +160,7 @@ def run_dependency_scanner(package_manager='', input_dir='', output_dir_file='',
151160
found_package_manager = {}
152161
if autodetect:
153162
try:
154-
ret, found_package_manager, input_dir = find_package_manager(input_dir)
163+
ret, found_package_manager, input_dir = find_package_manager(input_dir, abs_path_to_exclude)
155164
os.chdir(input_dir)
156165
except Exception as e:
157166
logger.error(f'Fail to find package manager: {e}')
@@ -188,7 +197,8 @@ def run_dependency_scanner(package_manager='', input_dir='', output_dir_file='',
188197
fail_pm.append(f"{pm} ({', '.join(manifest_file_name)})")
189198
cover = CoverItem(tool_name=_PKG_NAME,
190199
start_time=_start_time,
191-
input_path=input_dir)
200+
input_path=input_dir,
201+
exclude_path=path_to_exclude)
192202
cover_comment_arr = []
193203
if len(found_package_manager.keys()) > 0:
194204
if len(success_pm) > 0:
@@ -231,6 +241,7 @@ def main():
231241
package_manager = ''
232242
input_dir = ''
233243
output_dir = ''
244+
path_to_exclude = []
234245
pip_activate_cmd = ''
235246
pip_deactivate_cmd = ''
236247
output_custom_dir = ''
@@ -244,6 +255,7 @@ def main():
244255
parser.add_argument('-v', '--version', action='store_true', required=False)
245256
parser.add_argument('-m', '--manager', nargs=1, type=str, default='', required=False)
246257
parser.add_argument('-p', '--path', nargs=1, type=str, required=False)
258+
parser.add_argument('-e', '--exclude', nargs='*', required=False, default=[])
247259
parser.add_argument('-o', '--output', nargs=1, type=str, required=False)
248260
parser.add_argument('-a', '--activate', nargs=1, type=str, default='', required=False)
249261
parser.add_argument('-d', '--deactivate', nargs=1, type=str, default='', required=False)
@@ -268,6 +280,8 @@ def main():
268280
package_manager = ''.join(args.manager)
269281
if args.path: # -p option
270282
input_dir = ''.join(args.path)
283+
if args.exclude: # -e option
284+
path_to_exclude = args.exclude
271285
if args.output: # -o option
272286
output_dir = ''.join(args.output)
273287
if args.activate: # -a option
@@ -301,7 +315,7 @@ def main():
301315
sys.exit(0)
302316

303317
run_dependency_scanner(package_manager, input_dir, output_dir, pip_activate_cmd, pip_deactivate_cmd,
304-
output_custom_dir, app_name, github_token, format, direct)
318+
output_custom_dir, app_name, github_token, format, direct, path_to_exclude)
305319

306320

307321
if __name__ == '__main__':

tests/test_exclude/pubspec.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: iamport_flutter
2+
description: Plugin that allows Flutter to use Iamport payment and certification functions.
3+
version: 0.10.0-dev.1
4+
homepage: https://github.com/iamport/iamport_flutter
5+
6+
environment:
7+
sdk: '>=2.12.0 <3.0.0'
8+
flutter: ">=2.0.0"
9+
10+
dependencies:
11+
flutter:
12+
sdk: flutter
13+
iamport_webview_flutter: ^3.0.1
14+
url_launcher: ^6.0.4
15+
dev_dependencies:
16+
dart_json_mapper: ^2.1.0
17+
uni_links: ^0.5.1
18+
# For information on the generic Dart part of this file, see the
19+
# following page: https://www.dartlang.org/tools/pub/pubspec
20+
21+
# The following section is specific to Flutter.
22+
flutter:
23+
# This section identifies this Flutter project as a plugin project.
24+
# The androidPackage and pluginClass identifiers should not ordinarily
25+
# be modified. They are used by the tooling to maintain consistency when
26+
# adding or updating assets for this project.
27+
plugin:
28+
platforms:
29+
android:
30+
package: kr.iamport.iamport_flutter
31+
pluginClass: IamportFlutterPlugin
32+
ios:
33+
pluginClass: IamportFlutterPlugin
34+
35+
uses-material-design: true
36+
37+
# To add assets to your plugin package, add an assets section, like this:
38+
assets:
39+
- assets/images/iamport-logo.png
40+
41+
#
42+
# For details regarding assets in packages, see
43+
# https://flutter.dev/assets-and-images/#from-packages
44+
#
45+
# An image asset can refer to one or more resolution-specific "variants", see
46+
# https://flutter.dev/assets-and-images/#resolution-aware.
47+
48+
# To add custom fonts to your plugin package, add a fonts section here,
49+
# in this "flutter" section. Each entry in this list should have a
50+
# "family" key with the font family name, and a "fonts" key with a
51+
# list giving the asset and other descriptors for the font. For
52+
# example:
53+
# fonts:
54+
# - family: Schyler
55+
# fonts:
56+
# - asset: fonts/Schyler-Regular.ttf
57+
# - asset: fonts/Schyler-Italic.ttf
58+
# style: italic
59+
# - family: Trajan Pro
60+
# fonts:
61+
# - asset: fonts/TrajanPro.ttf
62+
# - asset: fonts/TrajanPro_Bold.ttf
63+
# weight: 700
64+
#
65+
# For details regarding fonts in packages, see
66+
# https://flutter.dev/custom-fonts/#from-packages

tests/test_exclude/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
openpyxl
2+
virtualenv

0 commit comments

Comments
 (0)