-
Notifications
You must be signed in to change notification settings - Fork 32
new check: variables that should be quoted #379
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
testdata/data/repos/eclass/EclassUnquotedVariablesCheck/EclassUnquotedVariable/expected.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"__class__": "EclassUnquotedVariable", "eclass": "unquotedvariable", "variable": "DISTDIR", "lines": [19]} |
3 changes: 3 additions & 0 deletions
3
...a/data/repos/standalone/EbuildUnquotedVariablesCheck/EbuildUnquotedVariable/expected.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| {"__class__": "EbuildUnquotedVariable", "category": "EbuildUnquotedVariablesCheck", "package": "EbuildUnquotedVariable", "version": "0", "variable": "FILESDIR", "lines": [9, 19]} | ||
| {"__class__": "EbuildUnquotedVariable", "category": "EbuildUnquotedVariablesCheck", "package": "EbuildUnquotedVariable", "version": "0", "variable": "T", "lines": [25, 27, 41, 42]} | ||
| {"__class__": "EbuildUnquotedVariable", "category": "EbuildUnquotedVariablesCheck", "package": "EbuildUnquotedVariable", "version": "0", "variable": "WORKDIR", "lines": [34]} |
46 changes: 46 additions & 0 deletions
46
testdata/data/repos/standalone/EbuildUnquotedVariablesCheck/EbuildUnquotedVariable/fix.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| --- standalone/EbuildUnquotedVariablesCheck/EbuildUnquotedVariable/EbuildUnquotedVariable-0.ebuild 2022-05-18 20:27:34.657647175 +0200 | ||
| +++ fixed/EbuildUnquotedVariablesCheck/EbuildUnquotedVariable/EbuildUnquotedVariable-0.ebuild 2022-05-18 20:50:00.271294657 +0200 | ||
| @@ -6,7 +6,7 @@ | ||
| S=${WORKDIR}/${PV} # ok | ||
|
|
||
| PATCHES=( | ||
| - ${FILESDIR}/foo.patch # FAIL | ||
| + "${FILESDIR}"/foo.patch # FAIL | ||
| "${FILESDIR}"/foo.patch # ok | ||
| "${FILESDIR}/foo.patch" # ok | ||
| ) | ||
| @@ -16,28 +16,28 @@ | ||
| : | ||
| fi | ||
|
|
||
| - if has "foo" ${FILESDIR} ; then # FAIL | ||
| + if has "foo" "${FILESDIR}" ; then # FAIL | ||
| : | ||
| fi | ||
|
|
||
| local t=${T} # ok | ||
| local t=${T}/t # ok | ||
| - emake CC=${T}; someotherfunc ${T} # FAIL | ||
| + emake CC="${T}"; someotherfunc "${T}" # FAIL | ||
|
|
||
| - local var=( TMP=${T} ) # FAIL | ||
| + local var=( TMP="${T}" ) # FAIL | ||
|
|
||
| cat > "${T}"/somefile <<- EOF || die | ||
| PATH="${EPREFIX}${INSTALLDIR}/bin" | ||
| EOF | ||
| doenvd "${T}"/10stuffit # ok | ||
|
|
||
| - echo "InitiatorName=$(${WORKDIR}/usr/sbin/iscsi-iname)" # FAIL | ||
| + echo "InitiatorName=$("${WORKDIR}"/usr/sbin/iscsi-iname)" # FAIL | ||
| einfo ${WORKDIR} # ok | ||
|
|
||
| if grep -qs '^ *sshd *:' "${WORKDIR}"/etc/hosts.{allow,deny} ; then # ok | ||
| ewarn "something something ${WORKDIR} here" | ||
| fi | ||
|
|
||
| - cat < ${T} # FAIL | ||
| - cat >> ${T} # FAIL | ||
| + cat < "${T}" # FAIL | ||
| + cat >> "${T}" # FAIL | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Copyright 2022 Gentoo Authors | ||
| # Distributed under the terms of the GNU General Public License v2 | ||
|
|
||
| # @ECLASS: unquotedvariable.eclass | ||
| # @MAINTAINER: | ||
| # Larry the Cow <larry@gentoo.org> | ||
| # @AUTHOR: | ||
|
arthurzam marked this conversation as resolved.
|
||
| # Larry the Cow <larry@gentoo.org> | ||
| # @SUPPORTED_EAPIS: 8 | ||
| # @BLURB: Eclass that forgets to quote a variable properly | ||
| # @DESCRIPTION: | ||
| # A small eclass that defines a single variable, but references a variable that | ||
| # needs to be quoted in specific contexts. | ||
|
|
||
| # @ECLASS_VARIABLE: EBZR_STORE_DIR | ||
| # @USER_VARIABLE | ||
| # @DESCRIPTION: | ||
| # The directory to store all fetched Bazaar live sources. | ||
| : ${EBZR_STORE_DIR:=${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/bzr-src} | ||
43 changes: 43 additions & 0 deletions
43
...alone/EbuildUnquotedVariablesCheck/EbuildUnquotedVariable/EbuildUnquotedVariable-0.ebuild
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| EAPI=8 | ||
| DESCRIPTION="Ebuild with variables that must be quoted" | ||
| HOMEPAGE="https://github.com/pkgcore/pkgcheck" | ||
| SLOT="0" | ||
| LICENSE="BSD" | ||
| S=${WORKDIR}/${PV} # ok | ||
|
|
||
| PATCHES=( | ||
| ${FILESDIR}/foo.patch # FAIL | ||
| "${FILESDIR}"/foo.patch # ok | ||
| "${FILESDIR}/foo.patch" # ok | ||
| ) | ||
|
|
||
| src_prepare() { | ||
| if [[ -z ${S} ]]; then # ok | ||
| : | ||
| fi | ||
|
|
||
| if has "foo" ${FILESDIR} ; then # FAIL | ||
| : | ||
| fi | ||
|
|
||
| local t=${T} # ok | ||
| local t=${T}/t # ok | ||
| emake CC=${T}; someotherfunc ${T} # FAIL | ||
|
|
||
| local var=( TMP=${T} ) # FAIL | ||
|
|
||
| cat > "${T}"/somefile <<- EOF || die | ||
| PATH="${EPREFIX}${INSTALLDIR}/bin" | ||
| EOF | ||
| doenvd "${T}"/10stuffit # ok | ||
|
|
||
| echo "InitiatorName=$(${WORKDIR}/usr/sbin/iscsi-iname)" # FAIL | ||
| einfo ${WORKDIR} # ok | ||
|
|
||
| if grep -qs '^ *sshd *:' "${WORKDIR}"/etc/hosts.{allow,deny} ; then # ok | ||
| ewarn "something something ${WORKDIR} here" | ||
| fi | ||
|
arthurzam marked this conversation as resolved.
|
||
|
|
||
| cat < ${T} # FAIL | ||
| cat >> ${T} # FAIL | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.