From 11935c1cc36b80455759a2795be7eee396dab7e3 Mon Sep 17 00:00:00 2001 From: Tom Fay Date: Wed, 15 Dec 2021 14:46:29 +0000 Subject: [PATCH] Add poetry detector (#23) Co-authored-by: Jamie Magee --- README.md | 1 + docs/creating-a-new-detector.md | 2 +- docs/detectors/README.md | 1 + docs/detectors/poetry.md | 11 ++ docs/feature-overview.md | 1 + .../poetry/Contracts/PoetryLock.cs | 12 ++ .../poetry/Contracts/PoetryPackage.cs | 21 +++ .../poetry/Contracts/PoetrySource.cs | 21 +++ .../poetry/PoetryComponentDetector.cs | 54 +++++++ .../PoetryComponentDetectorTests.cs | 149 ++++++++++++++++++ 10 files changed, 272 insertions(+), 1 deletion(-) create mode 100644 docs/detectors/poetry.md create mode 100644 src/Microsoft.ComponentDetection.Detectors/poetry/Contracts/PoetryLock.cs create mode 100644 src/Microsoft.ComponentDetection.Detectors/poetry/Contracts/PoetryPackage.cs create mode 100644 src/Microsoft.ComponentDetection.Detectors/poetry/Contracts/PoetrySource.cs create mode 100644 src/Microsoft.ComponentDetection.Detectors/poetry/PoetryComponentDetector.cs create mode 100644 test/Microsoft.ComponentDetection.Detectors.Tests/PoetryComponentDetectorTests.cs diff --git a/README.md b/README.md index 406f1ac0..a7289091 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ ComponentDetection is a package scanning tool intended to be used at build time. | NPM (including Yarn, Pnpm) | ✔ | ✔ | | NuGet | ✔ | ✔ | | Pip (Python) | ✔ | ✔ | +| Poetry (Python, lockfiles only) | ✔ | ❌ | | Ruby | ✔ | ✔ | | Rust | ✔ | ✔ | diff --git a/docs/creating-a-new-detector.md b/docs/creating-a-new-detector.md index f041a739..1443904f 100644 --- a/docs/creating-a-new-detector.md +++ b/docs/creating-a-new-detector.md @@ -129,7 +129,7 @@ From the example above you can see each test is initialized with a new `Detector ## How to run/debug your detector ``` -dotnet run -p "[YOUR REPO PATH]\src\Microsoft.ComponentDetection\Microsoft.ComponentDetection.csproj" scan +dotnet run --project "[YOUR REPO PATH]\src\Microsoft.ComponentDetection\Microsoft.ComponentDetection.csproj" scan --Verbosity Verbose --SourceDirectory [PATH TO THE REPO TO SCAN] --DetectorArgs [YOUR DETECTOR ID]=EnableIfDefaultOff diff --git a/docs/detectors/README.md b/docs/detectors/README.md index a08d566e..34012c2e 100644 --- a/docs/detectors/README.md +++ b/docs/detectors/README.md @@ -8,5 +8,6 @@ - NPM - NuGet - [Pip](pip.md) +- [Poetry](poetry.md) - Ruby - Rust diff --git a/docs/detectors/poetry.md b/docs/detectors/poetry.md new file mode 100644 index 00000000..fbf1a6f1 --- /dev/null +++ b/docs/detectors/poetry.md @@ -0,0 +1,11 @@ +# Poetry Detection +## Requirements +Poetry detection relies on a poetry.lock file being present. + +## Detection strategy +Poetry detection is performed by parsing a poetry.lock found under the scan directory. + +## Known limitations +Poetry detection will not work if lock files are not being used. + +Full dependency graph generation is not supported. diff --git a/docs/feature-overview.md b/docs/feature-overview.md index d27784fc..8828e464 100644 --- a/docs/feature-overview.md +++ b/docs/feature-overview.md @@ -13,6 +13,7 @@ | Pnpm | | - | ✔ (packages/{package}/dev flag) | ✔ | | NuGet | | - | - | ✔ (required project.assets.json) | | Pip (Python) | | | ❌ | ✔ | +| Poetry (Python) |