-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(github_scripts): improve code formatting #74
Conversation
…ary code\n \n ✨ Removed unused code and improved code formatting for better readability.\n
The default action is to increase the PATCH number of SEMVER. Set IGNORE-FOR-RELEASE if you want to skip SEMVER bump. BREAKING-CHANGE and NEW-RELEASE must be run from GH Actions section manually. |
This pull request does not contain a valid label. Please add one of the following labels: |
The default action is to increase the |
const execSync = require('child_process').execSync; | ||
for (const file of IGNORED_FILES.trim().split(',')) { | ||
|
||
const ignored_additions_str = execSync('git --no-pager diff --numstat origin/main..origin/' + BRANCH_NAME + ' | grep ' + file + ' | cut -f 1', {encoding: 'utf-8'}) |
Check warning
Code scanning / CodeQL
Indirect uncontrolled command line Medium
environment variable
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 12 days ago
To fix the problem, we should avoid using execSync
with a concatenated string and instead use execFileSync
which accepts command arguments as an array of strings. This approach is safer and prevents command injection vulnerabilities. We will need to modify the lines where execSync
is used to execute the git
commands and replace them with execFileSync
.
-
Copy modified line R11 -
Copy modified lines R14-R23
@@ -10,7 +10,15 @@ | ||
var ignored = 0 | ||
const execSync = require('child_process').execSync; | ||
const { execFileSync } = require('child_process'); | ||
for (const file of IGNORED_FILES.trim().split(',')) { | ||
|
||
const ignored_additions_str = execSync('git --no-pager diff --numstat origin/main..origin/' + BRANCH_NAME + ' | grep ' + file + ' | cut -f 1', {encoding: 'utf-8'}) | ||
const ignored_deletions_str = execSync('git --no-pager diff --numstat origin/main..origin/' + BRANCH_NAME + ' | grep ' + file + ' | cut -f 2', {encoding: 'utf-8'}) | ||
const ignored_additions_str = execFileSync('git', ['--no-pager', 'diff', '--numstat', `origin/main..origin/${BRANCH_NAME}`], { encoding: 'utf-8' }) | ||
.split('\n') | ||
.filter(line => line.includes(file)) | ||
.map(line => line.split('\t')[0]) | ||
.join('\n'); | ||
const ignored_deletions_str = execFileSync('git', ['--no-pager', 'diff', '--numstat', `origin/main..origin/${BRANCH_NAME}`], { encoding: 'utf-8' }) | ||
.split('\n') | ||
.filter(line => line.includes(file)) | ||
.map(line => line.split('\t')[1]) | ||
.join('\n'); | ||
|
for (const file of IGNORED_FILES.trim().split(',')) { | ||
|
||
const ignored_additions_str = execSync('git --no-pager diff --numstat origin/main..origin/' + BRANCH_NAME + ' | grep ' + file + ' | cut -f 1', {encoding: 'utf-8'}) | ||
const ignored_deletions_str = execSync('git --no-pager diff --numstat origin/main..origin/' + BRANCH_NAME + ' | grep ' + file + ' | cut -f 2', {encoding: 'utf-8'}) |
Check warning
Code scanning / CodeQL
Indirect uncontrolled command line Medium
environment variable
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
This PR exceeds the recommended size of 400 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size. |
List of Changes
✨ Removed unused code and improved code formatting for better readability.
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
expected)
Checklist: