Skip to content

Dataflow: Deprecate FlowStateString. #15062

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

Merged

Conversation

aschackmull
Copy link
Contributor

Followup for #14983. I don't think we need a change note for this, as this was effectively part of the old api.

@aschackmull aschackmull added the no-change-note-required This PR does not need a change note label Dec 11, 2023
@aschackmull aschackmull marked this pull request as draft December 11, 2023 10:21
@aschackmull aschackmull force-pushed the dataflow/deprecate-flowstatestring branch from a026252 to edd6583 Compare December 11, 2023 10:28
@aschackmull aschackmull marked this pull request as ready for review December 11, 2023 10:28
@aschackmull aschackmull requested review from a team as code owners December 11, 2023 10:28
@jketema
Copy link
Contributor

jketema commented Dec 11, 2023

Fix for the coding standards tests: github/codeql-coding-standards#473

owen-mc
owen-mc previously approved these changes Dec 11, 2023
Copy link
Contributor

@owen-mc owen-mc left a comment

Choose a reason for hiding this comment

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

Go LGTM

atorralba
atorralba previously approved these changes Dec 12, 2023
Copy link
Contributor

@atorralba atorralba left a comment

Choose a reason for hiding this comment

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

Java 👍

I don't think we need a change note for this, as this was effectively part of the old api.

Agree, everything affected by this seems to be under the internal directory.

Copy link
Contributor

@michaelnebel michaelnebel left a comment

Choose a reason for hiding this comment

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

C# LGTM - but there are some tests failing for other languages.

@jketema
Copy link
Contributor

jketema commented Dec 12, 2023

@aschackmull The coding standards tests are now fixed.

Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

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

👍 for Swift.

geoffw0
geoffw0 previously approved these changes Dec 12, 2023
@geoffw0
Copy link
Contributor

geoffw0 commented Dec 12, 2023

Oh, one of the test failures is in Swift. There was briefly a version of main with failing Swift tests (that I think looked like what we have here), it's possible this PR has got unlucky with it's base commit?

@aschackmull
Copy link
Contributor Author

Oh, one of the test failures is in Swift. There was briefly a version of main with failing Swift tests (that I think looked like what we have here), it's possible this PR has got unlucky with it's base commit

Yes. I'm aware I need to rebase, and that should fix the swift test. But there's also a Java failure, so I was planning to fix that before rebasing. (No need to rerun CI twice).

yoff
yoff previously approved these changes Dec 13, 2023
Copy link
Contributor

@yoff yoff left a comment

Choose a reason for hiding this comment

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

Python 👍

@aschackmull aschackmull dismissed stale reviews from yoff, geoffw0, atorralba, and owen-mc via f2dea89 December 14, 2023 14:05
@aschackmull aschackmull force-pushed the dataflow/deprecate-flowstatestring branch from 7b4c0db to f2dea89 Compare December 14, 2023 14:05
@aschackmull
Copy link
Contributor Author

@atorralba could you take a look at the last commit - I've fixed the 3 java queries that had accidental exposure of FlowStateString in their extension points.

jketema
jketema previously approved these changes Dec 14, 2023
Copy link
Contributor

@atorralba atorralba left a comment

Choose a reason for hiding this comment

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

Ok, so the last commit mostly LGTM.

  • ImplictPendingIntents 👍
  • Turns out that we didn't even use FlowStates in TemplateInjection, and I made those extension points "just in case" 😅. Anyway, 👍.
  • I think I followed your changes in InsufficientKeySize. AFAIU there aren't changes in the semantics (and the green tests probably confirm this), so we should be good. Still, I added a few minor comments/questions.

/** Holds if this sink has the specified `state`. */
predicate hasState(DataFlow::FlowState state) { state instanceof DataFlow::FlowStateEmpty }
/** Holds if this sink accepts the specified `state`. */
final predicate hasState(KeySizeState state) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Couldn't this break existing implementations of InsufficientKeySizeSink overriding hasState?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.


/** A source for an insufficient key size. */
abstract class InsufficientKeySizeSource extends DataFlow::Node {
/** Holds if this source has the specified `state`. */
predicate hasState(DataFlow::FlowState state) { state instanceof DataFlow::FlowStateEmpty }
abstract predicate hasState(KeySizeState state);
Copy link
Contributor

Choose a reason for hiding this comment

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

Couldn't this break existing implementations of InsufficientKeySizeSource that don't override hasState?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but such a hypothetical source wouldn't make much sense. Its default state would not match any sink, so it wouldn't work. Hence, I find it unlikely that this extension point has been used in the wild. Really, as the query is written, we need a key size state to be specified for the sources and the sinks, and with the way that I've reimplemented the logic I found it hard to provide a straight-forward deprecation path from the old interface.

I guess we could put in some work provide a better deprecation path by renaming the hasState predicate and providing a translation from the old to the new, but it's not going to be neither pretty nor simple, do you think that's worth it? I was leaning towards risking breakage here as my preferred option.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was just making sure this was a deliberate decision. I also favor the cleanest path forward (if we are allowed to break things when we believe it makes sense, which I didn't know 😄).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a calculated risk and one that we generally try hard to avoid. But adding a new abstract predicate isn't really possible to do without potential breakage.

@aschackmull aschackmull merged commit 1ea1130 into github:main Dec 15, 2023
@aschackmull aschackmull deleted the dataflow/deprecate-flowstatestring branch December 15, 2023 10:59
Gooners4immortalityonmeth

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants