Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: GitGuardian/ggshield
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.38.0
Choose a base ref
...
head repository: GitGuardian/ggshield
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.38.1
Choose a head ref
  • 5 commits
  • 15 files changed
  • 4 contributors

Commits on Mar 27, 2025

  1. chore(pre-commit): update to ggshield 1.38.0

    gg-jonathangriffe committed Mar 27, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2fb6f7a View commit details

Commits on Mar 28, 2025

  1. Merge pull request #1073 from GitGuardian/jonathangriffe/update-ggshi…

    …eld-version
    
    chore(pre-commit): update to ggshield 1.38.0
    gg-jonathangriffe authored Mar 28, 2025
    Copy the full SHA
    22a8136 View commit details

Commits on Apr 2, 2025

  1. feat(cmd_archive): Add support for .jar files

    salome-voltz committed Apr 2, 2025
    Copy the full SHA
    4ff1855 View commit details
  2. Merge pull request #1077 from GitGuardian/salomevoltz/scrt-5449-make-…

    …ggshield-able-to-scan-jar-files
    
    feat(cmd_archive): Add support for .jar files
    salome-voltz authored Apr 2, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d3c75f4 View commit details
  3. chore(release): 1.38.1

    salome-voltz committed Apr 2, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f866bb8 View commit details
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -80,7 +80,7 @@ repos:
stages: [pre-push]

- repo: https://github.com/gitguardian/ggshield
rev: v1.37.0
rev: v1.38.0
hooks:
- id: ggshield
language_version: python3
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

<a id='changelog-1.38.1'></a>

## 1.38.1 — 2025-04-02

### Added

- ggshield can now scan .jar files using `ggshield secret scan archive`.

<a id='changelog-1.38.0'></a>

## 1.38.0 — 2025-03-27
2 changes: 1 addition & 1 deletion actions/secret/action.yml
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ inputs:

runs:
using: 'docker'
image: 'docker://gitguardian/ggshield:v1.38.0'
image: 'docker://gitguardian/ggshield:v1.38.1'
entrypoint: '/app/docker/actions-secret-entrypoint.sh'
args:
- ${{ inputs.args }}
2 changes: 1 addition & 1 deletion ggshield/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.38.0"
__version__ = "1.38.1"
2 changes: 1 addition & 1 deletion ggshield/cmd/secret/scan/archive.py
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ def archive_cmd(
**kwargs: Any,
) -> int: # pragma: no cover
"""
Scan an archive file. Supported archive formats are zip, tar, tar.gz, tar.bz2 and tar.xz.
Scan an archive file. Supported archive formats are zip, whl, jar, tar, tar.gz, tar.bz2 and tar.xz.
"""
with tempfile.TemporaryDirectory(suffix="ggshield") as temp_dir:
temp_path = Path(temp_dir)
4 changes: 2 additions & 2 deletions ggshield/utils/archive.py
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ def safe_unpack(archive: Path, extract_dir: Path) -> None:
check_archive_content(archive)

# unpack_archive does not know .whl files are zip files
archive_format = "zip" if archive.suffix == ".whl" else None
archive_format = "zip" if archive.suffix in {".whl", ".jar"} else None

shutil.unpack_archive(archive, extract_dir, format=archive_format)

@@ -55,7 +55,7 @@ def check_archive_content(archive: Path) -> None:
"""
Check `archive` safety, raise `UnsafeArchive` if it is unsafe.
"""
if archive.suffix in {".zip", ".whl"}:
if archive.suffix in {".zip", ".whl", ".jar"}:
_check_zip_content(archive)
else:
_check_tar_content(archive)
Binary file added tests/unit/data/archives/bad.jar
Binary file not shown.
Binary file modified tests/unit/data/archives/bad.tar
Binary file not shown.
Binary file modified tests/unit/data/archives/bad.zip
Binary file not shown.
13 changes: 11 additions & 2 deletions tests/unit/data/archives/generate-archives
Original file line number Diff line number Diff line change
@@ -20,12 +20,14 @@ set -euo pipefail
cd "$(dirname "$0")"
BAD_ZIP=$PWD/bad.zip
BAD_TAR=$PWD/bad.tar
BAD_JAR=$PWD/bad.jar

GOOD_ZIP=$PWD/good.zip
GOOD_WHL=$PWD/good.whl
GOOD_TAR=$PWD/good.tar
GOOD_JAR=$PWD/good.jar

rm -f "$BAD_ZIP" "$BAD_TAR" "$GOOD_ZIP" "$GOOD_TAR" "$GOOD_WHL"
rm -f "$BAD_ZIP" "$BAD_TAR" "$BAD_JAR" "$GOOD_ZIP" "$GOOD_TAR" "$GOOD_WHL" "$GOOD_JAR"

rm -rf work
mkdir -p work/archive-root
@@ -52,6 +54,11 @@ mkdir -p work/archive-root/subdir
ZIP_CMD="7z a"
7z a -spf -snl "$BAD_ZIP" ../bad-relative /tmp/bad-absolute . > /dev/null
7z a "$GOOD_ZIP" fine subdir/fine-symlink > /dev/null

# A .jar is a .zip with a different extension

cp "$BAD_ZIP" "$BAD_JAR"
cp "$GOOD_ZIP" "$GOOD_JAR"

# A .whl is a .zip with a different extension
cp "$GOOD_ZIP" "$GOOD_WHL"
@@ -65,6 +72,8 @@ rm -rf work
echo "Generated:
$BAD_ZIP
$BAD_TAR
$BAD_JAR
$GOOD_ZIP
$GOOD_WHL
$GOOD_TAR"
$GOOD_TAR
$GOOD_JAR"
Binary file added tests/unit/data/archives/good.jar
Binary file not shown.
Binary file modified tests/unit/data/archives/good.tar
Binary file not shown.
Binary file modified tests/unit/data/archives/good.whl
Binary file not shown.
Binary file modified tests/unit/data/archives/good.zip
Binary file not shown.
10 changes: 7 additions & 3 deletions tests/unit/utils/test_archive.py
Original file line number Diff line number Diff line change
@@ -16,12 +16,14 @@
ARCHIVES_PATH = DATA_PATH / "archives"
BAD_ZIP_PATH = ARCHIVES_PATH / "bad.zip"
BAD_TAR_PATH = ARCHIVES_PATH / "bad.tar"
BAD_JAR_PATH = ARCHIVES_PATH / "bad.jar"
GOOD_ZIP_PATH = ARCHIVES_PATH / "good.zip"
GOOD_WHL_PATH = ARCHIVES_PATH / "good.whl"
GOOD_TAR_PATH = ARCHIVES_PATH / "good.tar"
GOOD_JAR_PATH = ARCHIVES_PATH / "good.jar"

"""
Both bad.zip and bad.tar have the same content:
Both bad.zip, bad.tar, and bad.jar have the same content:
./
./fine
@@ -34,7 +36,7 @@
"""


@pytest.mark.parametrize("archive", [BAD_ZIP_PATH, BAD_TAR_PATH])
@pytest.mark.parametrize("archive", [BAD_ZIP_PATH, BAD_TAR_PATH, BAD_JAR_PATH])
def test_check_archive_content_raises_exception(archive: Path):
"""
GIVEN a bad archive
@@ -62,7 +64,9 @@ def test_check_archive_content_raises_exception(archive: Path):
assert "bad-absolute-symlink" in message


@pytest.mark.parametrize("archive", [GOOD_ZIP_PATH, GOOD_WHL_PATH, GOOD_TAR_PATH])
@pytest.mark.parametrize(
"archive", [GOOD_ZIP_PATH, GOOD_WHL_PATH, GOOD_TAR_PATH, GOOD_JAR_PATH]
)
def test_check_safe_unpack(tmp_path: Path, archive: Path):
"""
GIVEN a good archive