Skip to content

Commit b5a643c

Browse files
authored
Adding support to ignore what files have changed in the commit (#11)
1 parent a71ec42 commit b5a643c

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The Socket Security CLI was created to enable integrations with other tools like
88
socketcli [-h] [--api_token API_TOKEN] [--repo REPO] [--branch BRANCH] [--committer COMMITTER] [--pr_number PR_NUMBER]
99
[--commit_message COMMIT_MESSAGE] [--default_branch] [--target_path TARGET_PATH] [--scm {api,github,gitlab}] [--sbom-file SBOM_FILE]
1010
[--commit-sha COMMIT_SHA] [--generate-license GENERATE_LICENSE] [-v] [--enable-debug] [--enable-json] [--disable-overview]
11-
[--disable-security-issue] [--files FILES]
11+
[--disable-security-issue] [--files FILES] [--ignore-commit-files]
1212
````
1313

1414
If you don't want to provide the Socket API Token every time then you can use the environment variable `SOCKET_SECURITY_API_KEY`
@@ -36,3 +36,4 @@ If you don't want to provide the Socket API Token every time then you can use th
3636
| --disable-overview | | False | False | If enabled will disable Dependency Overview comments |
3737
| --disable-security-issue | | False | False | If enabled will disable Security Issue Comments |
3838
| --files | | False | | If provided in the format of `["file1", "file2"]` it will only look for those files and not glob the path |
39+
| --ignore-commit-files | | False | False | If enabled then the CLI will ignore what files are changed in the commit and look for all manifest files |

socketsecurity/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
__author__ = 'socket.dev'
2-
__version__ = '0.0.95'
2+
__version__ = '0.0.98'

socketsecurity/socketcli.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,13 @@
135135
default="[]"
136136
)
137137

138+
parser.add_argument(
139+
'--ignore-commit-files',
140+
help='Ignores only looking for changed files form the commit. Will find any supported manifest file type',
141+
action='store_true',
142+
default=False
143+
)
144+
138145

139146
def output_console_comments(diff_report) -> None:
140147
console_security_comment = Messages.create_console_security_alert_table(diff_report)
@@ -187,6 +194,7 @@ def main_code():
187194
enable_json = arguments.enable_json
188195
disable_overview = arguments.disable_overview
189196
disable_security_issue = arguments.disable_security_issue
197+
ignore_commit_files = arguments.ignore_commit_files
190198
files = arguments.files
191199
log.info(f"Starting Socket Security Scan version {__version__}")
192200
api_token = os.getenv("SOCKET_SECURITY_API_KEY") or arguments.api_token
@@ -211,7 +219,7 @@ def main_code():
211219
committer = git_repo.committer
212220
if commit_message is None or commit_message == '':
213221
commit_message = git_repo.commit_message
214-
if len(files) == 0:
222+
if len(files) == 0 and not ignore_commit_files:
215223
files = git_repo.changed_files
216224
except InvalidGitRepositoryError:
217225
pass

0 commit comments

Comments
 (0)