Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sast): unhandled errors flagged by cxSAST #3095

Merged
merged 3 commits into from
May 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pkg/parser/utils/certificate_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ func getCertificateInfo(filePath string) (certInfo, error) {
func AddCertificateInfo(path, content string) map[string]interface{} {
var filePath string

if _, err := os.Stat(content); err != nil { // content is not a full valid path or is an incomplete path
_, err := os.Stat(content)

if err != nil { // content is not a full valid path or is an incomplete path
log.Trace().Msgf("path to the certificate content is not a valid: %s", content)
filePath = filepath.Join(filepath.Dir(path), content)
} else { // content is a full valid path
filePath = content
Expand Down
7 changes: 6 additions & 1 deletion pkg/parser/utils/swagger_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ package utils
import (
"os"
"path/filepath"

"github.com/rs/zerolog/log"
)

// AddSwaggerInfo gets and adds the content of a swagger file
func AddSwaggerInfo(path, swaggerPath string) map[string]interface{} {
var filePath string

if _, err := os.Stat(swaggerPath); err != nil { // content is not a full valid path or is an incomplete path
_, err := os.Stat(swaggerPath)

if err != nil { // content is not a full valid path or is an incomplete path
log.Trace().Msgf("path to the swagger content specification is not a valid: %s", swaggerPath)
filePath = filepath.Join(filepath.Dir(path), swaggerPath)
} else { // content is a full valid path
filePath = swaggerPath
Expand Down