Skip to content

Commit

Permalink
[No Ticket] --detect-dynamic less error prone (#1376)
Browse files Browse the repository at this point in the history
* not found handled for dynamic deps

* update changelog

* fix fmt

* Update Changelog.md
  • Loading branch information
meghfossa authored Feb 9, 2024
1 parent d9c28a8 commit 2d37421
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# FOSSA CLI Changelog

## v3.9.1
- `--detect-dynamic`: Safely ignores scenarios in ldd output parsing where we run into not found error. ([#1376](https://github.com/fossas/fossa-cli/pull/1376))

## v3.9.0
- Emits a warning instead of an error when no analysis targets are found ([#1375](https://github.com/fossas/fossa-cli/pull/1375))

Expand Down
11 changes: 11 additions & 0 deletions src/App/Fossa/VSI/DynLinked/Internal/Binary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,23 @@ lddParseLocalDependencies =
( try lddConsumeSyscallLib
<|> try lddConsumeLinker
<|> try lddParseDependency
<|> try lddParseDependencyNotFound
)
<* eof

lddParseDependency :: Parser (Maybe LocalDependency)
lddParseDependency = Just <$> (LocalDependency <$> (linePrefix *> ident) <* symbol "=>" <*> path <* printedHex)

-- | Parses "not found" case for dependency
--
-- > libprotobuf.so.22 => not found
--
-- We want to ignore these, so we do not fatally fail in parsing.
lddParseDependencyNotFound :: Parser (Maybe LocalDependency)
lddParseDependencyNotFound = do
void $ linePrefix <* ident <* symbol "=>" <* symbol "not found"
pure Nothing

-- | The userspace library for system calls appears as the following in @ldd@ output:
--
-- > linux-vdso.so.1 => (0x00007ffc28d59000)
Expand Down
4 changes: 4 additions & 0 deletions test/App/Fossa/VSI/DynLinked/Internal/BinarySpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ spec = do
Hspec.it "should parse output with a single line" $ do
singleLine `shouldParseOutputInto` catMaybes [singleLineExpected]
singleLineMoreSpaces `shouldParseOutputInto` catMaybes [singleLineExpected]
singleLineNotFound `shouldParseOutputInto` []

Hspec.it "should parse output with multiple lines" $ do
multipleLine `shouldParseOutputInto` multipleLineExpected
Expand Down Expand Up @@ -65,6 +66,9 @@ shouldParseOutputInto = parseMatch Binary.lddParseLocalDependencies
singleLine :: Text
singleLine = "libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fbea9a88000)"

singleLineNotFound :: Text
singleLineNotFound = " libprotobuf.so.22 => not found"

singleLineMoreSpaces :: Text
singleLineMoreSpaces = " libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fbea9a88000) "

Expand Down

0 comments on commit 2d37421

Please sign in to comment.