-
Notifications
You must be signed in to change notification settings - Fork 25
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
Conversation
} | ||
if (!params.arguments || params.arguments.length === 0) { | ||
throw new Error(`Incorrect params provided. Params: ${params}`) | ||
throw new Error(`Error: Incorrect parameters parameters provided`) |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
} | ||
const [arg] = params.arguments | ||
|
||
logging.log(`Arguments provided: ${JSON.stringify(arg)}`) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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.