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

Ensure errors are useful message for security scan #355

Merged
merged 2 commits into from
Jun 28, 2024

Conversation

farisab1
Copy link
Contributor

Problem

Security scan error messages were vague and did not provide enough information on what the error being returned from LSP was

Solution

Update wording on error messages to describe the issue rather than returning internal objects

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@farisab1 farisab1 requested review from a team as code owners June 27, 2024 20:53
}
if (!params.arguments || params.arguments.length === 0) {
throw new Error(`Incorrect params provided. Params: ${params}`)
throw new Error(`Error: Incorrect parameters parameters provided`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the error text becomes user-facing, lets log (with logging) this error message, along with ${params}. This will let us diagnose the problem and see what the input is.

Meanwhile, we can make this error text less "technical" by saying something like "Error: Invalid data"

}
const [arg] = params.arguments
const { ActiveFilePath: activeFilePath, ProjectPath: projectPath } = parseJson(arg)
if (!activeFilePath || !projectPath) {
throw new Error(`Error: file path or project path not provided. Params: ${params}`)
if (!activeFilePath) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In each of these failure cases, it would be good to log the params payload. As the client, we will want to diagnose by understanding what we did or didn't send over to the server.

@farisab1 farisab1 requested a review from awschristou June 27, 2024 21:14
}
const [arg] = params.arguments

logging.log(`Arguments provided: ${JSON.stringify(arg)}`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this lead to sensitive data being logged or is it just path information?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just path information.

@farisab1 farisab1 merged commit ef53113 into main Jun 28, 2024
5 checks passed
@farisab1 farisab1 deleted the farisab/security-scan-error-updates branch June 28, 2024 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants