Skip to content

JS: Use API graphs in Vue model#6574

Merged
codeql-ci merged 29 commits into
github:mainfrom
asgerf:js/vue-api-graphs
Sep 7, 2021
Merged

JS: Use API graphs in Vue model#6574
codeql-ci merged 29 commits into
github:mainfrom
asgerf:js/vue-api-graphs

Conversation

@asgerf
Copy link
Copy Markdown
Contributor

@asgerf asgerf commented Aug 31, 2021

Makes the Vue model use API graphs where possible without breaking up the existing interface too much.

Evaluations:

  • Evaluation on the 30 vuex slugs looks OK. We gain 9 taint sources, 45 tainted nodes, and 101 (uninteresting) taint sinks.
  • I'm waiting for an evaluation on default slugs to check the performance impact for non-Vue apps.

@asgerf asgerf added JS Awaiting evaluation Do not merge yet, this PR is waiting for an evaluation to finish no-change-note-required This PR does not need a change note labels Aug 31, 2021
@asgerf asgerf requested a review from a team as a code owner August 31, 2021 09:27
Copy link
Copy Markdown
Contributor

@erik-krogh erik-krogh left a comment

Choose a reason for hiding this comment

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

Looks good 👍

I would prefer that the EntryPoint QlDoc states where the EntryPoint is needed.

And I think we could use getABulkExportedNode more (or we could wait with that if you prefer).

* Gets a value that is exported as the whole exports object of this module.
*/
cached
DataFlow::Node getABulkExportedNode() { none() } // overridden in subclasses
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Check out PackageExport.qll::getAnExportFromModule.
That also attempts to capture bulk exports.

I think you could add overrides for getABulkExportedNode in Closure::ClosureModule and AmdModule, and then use getABulkExportedNode in PackageExport.qll::getAnExportFromModule.

(That would also give you more complete support for other module types, although I doubt that's relevant for Vue).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Note that there was some dodgy behaviour in getAnExportFromModule regarding the use of type inference:

  result.analyze().getAValue() = mod.(AmdModule).getDefine().getAModuleExportsValue()

AFAICT, if the exported value was potentially undefined, then any node that could potentially be undefined would be seen as being an export from that AMD module 😖. (Likewise for any other abstract value, such as null)

It's hard to predict what effect this will have, and we might lose some results that were previously caught by chance because of this. For now I'll just evaluate on default slugs again, but maybe we should run something larger.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AFAICT, if the exported value was potentially undefined, then any node that could potentially be undefined would be seen as being an export from that AMD module confounded.

Oops. Luckily that can only happen if there exists such an AmdModule export in the project. And I expect that to be very rare.

Comment on lines +472 to +477
/**
* An import referring to a `.vue` file, seen as an API entry point.
*
* Concretely, such an import receives the Vue component generated from the .vue file,
* not the actual exports of the script tag in the file.
*/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add into the comment that this entrypoint is used in SingleFileComponent::getComponentRef().

override DataFlow::Node getARhs() { none() }
}

/** A value exported from a `.vue` file. */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
/** A value exported from a `.vue` file. */
/**
* A value exported from a `.vue` file.
* This `EntryPoint` is used by `SingleFileComponent::getOwnOptions()`.
*/

erik-krogh
erik-krogh previously approved these changes Sep 1, 2021
@asgerf
Copy link
Copy Markdown
Contributor Author

asgerf commented Sep 7, 2021

Evaluation on default slugs looks good. AFAICT the lost results are due to fixing the issue mentioned in #6574 (comment).

@asgerf asgerf removed the Awaiting evaluation Do not merge yet, this PR is waiting for an evaluation to finish label Sep 7, 2021
@codeql-ci codeql-ci merged commit 5b229e9 into github:main Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

JS no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants