Skip to content

Commit 2d37421

Browse files
authored
[No Ticket] --detect-dynamic less error prone (#1376)
* not found handled for dynamic deps * update changelog * fix fmt * Update Changelog.md
1 parent d9c28a8 commit 2d37421

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

Changelog.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# FOSSA CLI Changelog
22

3+
## v3.9.1
4+
- `--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))
5+
36
## v3.9.0
47
- Emits a warning instead of an error when no analysis targets are found ([#1375](https://github.com/fossas/fossa-cli/pull/1375))
58

src/App/Fossa/VSI/DynLinked/Internal/Binary.hs

+11
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,23 @@ lddParseLocalDependencies =
120120
( try lddConsumeSyscallLib
121121
<|> try lddConsumeLinker
122122
<|> try lddParseDependency
123+
<|> try lddParseDependencyNotFound
123124
)
124125
<* eof
125126

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

130+
-- | Parses "not found" case for dependency
131+
--
132+
-- > libprotobuf.so.22 => not found
133+
--
134+
-- We want to ignore these, so we do not fatally fail in parsing.
135+
lddParseDependencyNotFound :: Parser (Maybe LocalDependency)
136+
lddParseDependencyNotFound = do
137+
void $ linePrefix <* ident <* symbol "=>" <* symbol "not found"
138+
pure Nothing
139+
129140
-- | The userspace library for system calls appears as the following in @ldd@ output:
130141
--
131142
-- > linux-vdso.so.1 => (0x00007ffc28d59000)

test/App/Fossa/VSI/DynLinked/Internal/BinarySpec.hs

+4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ spec = do
3737
Hspec.it "should parse output with a single line" $ do
3838
singleLine `shouldParseOutputInto` catMaybes [singleLineExpected]
3939
singleLineMoreSpaces `shouldParseOutputInto` catMaybes [singleLineExpected]
40+
singleLineNotFound `shouldParseOutputInto` []
4041

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

69+
singleLineNotFound :: Text
70+
singleLineNotFound = " libprotobuf.so.22 => not found"
71+
6872
singleLineMoreSpaces :: Text
6973
singleLineMoreSpaces = " libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fbea9a88000) "
7074

0 commit comments

Comments
 (0)