繁体   English   中英

gosec 给出“无法导入 C(C 没有元数据)”golang 错误

[英]gosec giving “could not import C (no metadata for C)” golang error

我在我的项目上运行 gosec 但它给出了以下错误,因为我们的管道失败了

文件中的 Golang 错误:[/home/usr/exmaple/project.go]:

[第 22 行:第 8 列] - 无法导入 C(没有 C 的元数据)

而 go 构建命令成功构建项目意味着没有 golang 错误。

这似乎也是其他人遇到的错误。 请参阅此问题问题。 您可能也应该为此向 gosec 报告问题。 或者可能直接在 Go 存储库中的go/packages package 。

这不是问题。

We found out that our C code is present in.c and.h files in package directory, where.h file containing only function prototypes. 我们在 go 文件 (cgo) 中包含 only.h 文件。

go build and go test commands are working because both of these commands when see.c and.h in package directory, compiles and link them. But gosec is a SAST tool, it doesn't compile.c and.h files present in package directory due to this gosec scan was getting only function prototypes not definition and was throwing Golang error could not import C (no metadata for C).

在注释中包含整个代码 (CGO) 有效。 现在 gosec 工作正常。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM