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

Get full string for exported JavaScript results #18723

Open
ydelvis opened this issue Feb 10, 2025 · 4 comments
Open

Get full string for exported JavaScript results #18723

ydelvis opened this issue Feb 10, 2025 · 4 comments
Labels
question Further information is requested

Comments

@ydelvis
Copy link

ydelvis commented Feb 10, 2025

Consider the query below, which attempts to get the callee and the associated parameters. The returned string for the parameters is often truncated (sanitized) when the length is longer than 20 characters as seen in the source code. For instance, if the expected full string is bd0be325-86d9-4f16-95fa-b677f7455177, it returns something like bd0be ... 5177, which is not helpful for my project.

While there's a good reason for this behavior, I would really like to be able to export the full string for a follow-up analysis.

import javascript

from CallExpr call, Expr parameters
where 
    parameters = call.getArgument(_)

select call.getCallee(), parameters.toString()

I have seen a similar issue (results abbreviation #9890), but the suggestions do not address my problem.

I would really appreciate any support I can get here. Thank you.

@ydelvis ydelvis added the question Further information is requested label Feb 10, 2025
@jketema
Copy link
Contributor

jketema commented Feb 10, 2025

Hi @ydelvis

Thanks for your question. I've asked the CodeQL JavaScript team to take a look.

@erik-krogh
Copy link
Contributor

The string you get out will contain ... when you select a large piece of code, there is no way of getting around that.

If you're doing some followup analysis, what you could do instead is to use the location that you get out (are you exporting to .sarif?), and then write your own code to extract the relevant region from the file.

@ydelvis
Copy link
Author

ydelvis commented Feb 10, 2025

Hi @jketema and @erik-krogh, thank you for looking at this for me.

I'm currently exporting as .csv
I'll try working on an extraction code as suggested and see how it works out. I was really hoping there would be a straightforward fix/hack to get the desired results though. Thanks once again. I appreciate your prompt response.

@erik-krogh
Copy link
Contributor

I'm currently exporting as .csv

You could get the file-path and start/end column/lines as part of your select statement, then you could implement the thing I suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants