From 386430a9c1ba3f5ec0768fde01dbaad1d3e164c9 Mon Sep 17 00:00:00 2001 From: meghfossa <86321858+meghfossa@users.noreply.github.com> Date: Mon, 1 Nov 2021 14:12:52 -0600 Subject: [PATCH] Removes v1 compatibility mode (#383) --- Changelog.md | 6 +++++ spectrometer.cabal | 1 - src/App/Fossa/Compatibility.hs | 47 --------------------------------- src/App/Fossa/EmbeddedBinary.hs | 15 ----------- src/App/Fossa/Main.hs | 15 ----------- vendor_download.sh | 34 ------------------------ 6 files changed, 6 insertions(+), 112 deletions(-) delete mode 100644 src/App/Fossa/Compatibility.hs diff --git a/Changelog.md b/Changelog.md index ec1fb0c41..682ec5f89 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,11 @@ # Spectrometer Changelog +## v2.19.3 + +- Removes `fossa compatibility` command. ([#383](https://github.com/fossas/spectrometer/pull/383)) + +Use [`fossa-deps.{yml,json}`](docs/features/vendored-dependencies.md) file to facilitate archive uploading capability, previously provided by `fossa compatibility` command. + ## v2.19.2 - Adds `--config` flag, which can set custom path for configuration file. If `--config` flag is not used, base directory will scanned for `.fossa.yml` file. ([#415](https://github.com/fossas/spectrometer/pull/415)) diff --git a/spectrometer.cabal b/spectrometer.cabal index 85c65d41c..f2a4642ac 100644 --- a/spectrometer.cabal +++ b/spectrometer.cabal @@ -145,7 +145,6 @@ library App.Fossa.ArchiveUploader App.Fossa.BinaryDeps App.Fossa.BinaryDeps.Jar - App.Fossa.Compatibility App.Fossa.Configuration App.Fossa.Container App.Fossa.Container.Analyze diff --git a/src/App/Fossa/Compatibility.hs b/src/App/Fossa/Compatibility.hs deleted file mode 100644 index 0357fb84a..000000000 --- a/src/App/Fossa/Compatibility.hs +++ /dev/null @@ -1,47 +0,0 @@ -module App.Fossa.Compatibility ( - compatibilityMain, - argumentParser, - Argument, -) where - -import App.Fossa.EmbeddedBinary (BinaryPaths, toExecutablePath, withCLIv1Binary) -import Control.Carrier.StickyLogger (logSticky, runStickyLogger) -import Control.Effect.Lift (sendIO) -import Data.ByteString.Lazy.Char8 qualified as BL -import Data.String.Conversion (decodeUtf8) -import Data.Text (Text, pack) -import Effect.Exec (AllowErr (Never), CmdFailure (cmdFailureStdout), Command (..), cmdFailureStderr, exec, runExecIO) -import Effect.Logger (Pretty (pretty), Severity (SevInfo), logInfo, withDefaultLogger) -import Options.Applicative (Parser, argument, help, metavar, str) -import Path -import Path.IO (getCurrentDir) -import System.Exit (exitFailure, exitSuccess) - -type Argument = Text - -argumentParser :: Parser Argument -argumentParser = pack <$> argument str (metavar "ARGS" <> help "arguments to fossa v1 analyze") - -compatibilityMain :: - [Argument] -> - IO () -compatibilityMain args = withDefaultLogger SevInfo . runExecIO . withCLIv1Binary $ \v1Bin -> do - dir <- sendIO getCurrentDir - cmd <- runStickyLogger SevInfo $ do - logSticky "[ Waiting for fossa analyze completion ]" - exec dir $ v1Command v1Bin args - - case cmd of - Left err -> do - logInfo . pretty @Text . decodeUtf8 $ cmdFailureStderr err - logInfo . pretty @Text . decodeUtf8 $ cmdFailureStdout err - sendIO exitFailure - Right out -> sendIO (BL.putStr out >> exitSuccess) - -v1Command :: BinaryPaths -> [Text] -> Command -v1Command bin args = - Command - { cmdName = pack . toFilePath $ toExecutablePath bin - , cmdArgs = "analyze" : args - , cmdAllowErr = Never - } diff --git a/src/App/Fossa/EmbeddedBinary.hs b/src/App/Fossa/EmbeddedBinary.hs index e7ea793ed..8587aa9e5 100644 --- a/src/App/Fossa/EmbeddedBinary.hs +++ b/src/App/Fossa/EmbeddedBinary.hs @@ -10,7 +10,6 @@ module App.Fossa.EmbeddedBinary ( BinaryPaths, withWigginsBinary, withSyftBinary, - withCLIv1Binary, allBins, PackagedBinary (..), ) where @@ -27,7 +26,6 @@ import Prelude hiding (writeFile) data PackagedBinary = Syft | Wiggins - | CLIv1 deriving (Show, Eq, Enum, Bounded) allBins :: [PackagedBinary] @@ -57,14 +55,6 @@ withWigginsBinary :: m c withWigginsBinary = withEmbeddedBinary Wiggins -withCLIv1Binary :: - ( Has (Lift IO) sig m - , MonadIO m - ) => - (BinaryPaths -> m c) -> - m c -withCLIv1Binary = withEmbeddedBinary CLIv1 - withEmbeddedBinary :: ( Has (Lift IO) sig m , MonadIO m @@ -96,7 +86,6 @@ writeBinary :: (Has (Lift IO) sig m) => Path Abs File -> PackagedBinary -> m () writeBinary dest bin = sendIO . writeExecutable dest $ case bin of Syft -> embeddedBinarySyft Wiggins -> embeddedBinaryWiggins - CLIv1 -> embeddedBinaryCLIv1 writeExecutable :: Path Abs File -> ByteString -> IO () writeExecutable path content = do @@ -107,7 +96,6 @@ writeExecutable path content = do extractedPath :: PackagedBinary -> Path Rel File extractedPath bin = case bin of Syft -> $(mkRelFile "syft") - CLIv1 -> $(mkRelFile "cliv1") -- Rename wiggins upon local extraction so that we can provide a better status line to users during the VSI strategy. -- Users don't know what "wiggins" is, but they explicitly enable the VSI plugin, so this is more intuitive. Wiggins -> $(mkRelFile "vsi-plugin") @@ -131,6 +119,3 @@ embeddedBinaryWiggins = $(embedFileIfExists "vendor-bins/wiggins") embeddedBinarySyft :: ByteString embeddedBinarySyft = $(embedFileIfExists "vendor-bins/syft") - -embeddedBinaryCLIv1 :: ByteString -embeddedBinaryCLIv1 = $(embedFileIfExists "vendor-bins/cliv1") diff --git a/src/App/Fossa/Main.hs b/src/App/Fossa/Main.hs index fdec5f736..6880cd935 100644 --- a/src/App/Fossa/Main.hs +++ b/src/App/Fossa/Main.hs @@ -15,7 +15,6 @@ import App.Fossa.Analyze ( VSIAnalysisMode (..), analyzeMain, ) -import App.Fossa.Compatibility (Argument, argumentParser, compatibilityMain) import App.Fossa.Configuration ( ConfigFile ( configApiKey, @@ -300,9 +299,6 @@ appMain = do let apiOpts = ApiOpts optBaseUrl apikey assertUserDefinedBinariesMain logSeverity baseDir apiOpts assertionMeta -- - CompatibilityCommand args -> do - compatibilityMain args - -- DumpBinsCommand dir -> do basedir <- validateDir dir for_ Embed.allBins $ Embed.dumpEmbeddedBinary $ unBaseDir basedir @@ -412,12 +408,6 @@ hiddenCommands = (DumpBinsCommand <$> baseDirArg) (progDesc "Output all embedded binaries to specified path") ) - <> command - "compatibility" - ( info - (CompatibilityCommand <$> compatibilityOpts) - (progDesc "Run fossa cli v1 analyze. Supply arguments as \"fossa compatibility -- --project test\"") - ) <> command "experimental-link-user-defined-dependency-binary" ( info @@ -654,10 +644,6 @@ containerDumpScanOptions = <$> optional (strOption (short 'o' <> long "output-file" <> help "File to write the scan data (omit for stdout)")) <*> imageTextArg -compatibilityOpts :: Parser [Argument] -compatibilityOpts = - many argumentParser - assertUserDefinedBinariesOpts :: Parser AssertUserDefinedBinariesOptions assertUserDefinedBinariesOpts = AssertUserDefinedBinariesOptions @@ -692,7 +678,6 @@ data Command | VPSCommand VPSOptions | ContainerCommand ContainerOptions | AssertUserDefinedBinariesCommand AssertUserDefinedBinariesOptions - | CompatibilityCommand [Argument] | ListTargetsCommand FilePath | InitCommand | DumpBinsCommand FilePath diff --git a/vendor_download.sh b/vendor_download.sh index f5bfc531e..bfd988703 100755 --- a/vendor_download.sh +++ b/vendor_download.sh @@ -101,40 +101,6 @@ else echo "Forked Syft download successful" fi -if $OS_WINDOWS; then - echo "Skipping cliv1 for Windows builds" - touch vendor-bins/cliv1 -else - echo "" - echo "Downloading cliv1 binary" - CLIV1_RELEASE_JSON=vendor-bins/cliv1-release.json - curl -sSL \ - -H "Authorization: token $GITHUB_TOKEN" \ - -H "Accept: application/vnd.github.v3.raw" \ - api.github.com/repos/fossas/fossa-cli/releases/latest > $CLIV1_RELEASE_JSON - - # Remove leading 'v' from version tag - # 'v123' -> '123' - CLIV1_TAG=$(jq -cr '.name' $CLIV1_RELEASE_JSON | sed 's/^v//') - echo "Using fossas/fossa-cli release: $CLIV1_TAG" - FILTER=".name == \"fossa-cli_${CLIV1_TAG}_${ASSET_POSTFIX}_amd64.tar.gz\"" - jq -c ".assets | map({url: .url, name: .name}) | map(select($FILTER)) | .[]" $CLIV1_RELEASE_JSON | while read ASSET; do - URL="$(echo $ASSET | jq -c -r '.url')" - NAME="$(echo $ASSET | jq -c -r '.name')" - OUTPUT=vendor-bins/${NAME%"-$ASSET_POSTFIX"} - - echo "Downloading '$NAME' to '$OUTPUT'" - curl -sL -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/octet-stream" -s $URL > $OUTPUT - echo "Extracting cliv1 binary from tarball" - tar xzf $OUTPUT fossa - mv fossa vendor-bins/cliv1 - rm $OUTPUT - - done - rm $CLIV1_RELEASE_JSON - echo "CLI v1 download successful" -fi - echo "Marking binaries executable" chmod +x vendor-bins/*