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

Restore Serialize for two fuzz targets #572

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

adpaco-aws
Copy link
Contributor

Description of changes: Our fuzzers are built which --features log which in turn require the Serialize trait to be implemented for fuzz target inputs. cedar-policy/cedar#1520 removed the Serialize implementations from many core/validator types, but CI didn't catch it because we don't test the build with --features log.

This PR restores Serialize for two fuzz targets:

  • protobuf-roundtrip: We use #[serde(skip)] for each field except policy. This is how it's done in other targets, and I assume ValidatorSchema is safe to skip because it's built from Schema which is skipped in other targets as well.
  • wildcard-matching: We implement a simple custom serializer to avoid restoring it in cedar.

Signed-off-by: Adrian Palacios <accorell@amazon.com>
Signed-off-by: Adrian Palacios <accorell@amazon.com>
Signed-off-by: Adrian Palacios <accorell@amazon.com>
Copy link
Contributor

@john-h-kastner-aws john-h-kastner-aws left a comment

Choose a reason for hiding this comment

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

Looks fine. I still don't understand what we gain by building with log, so I wonder if we could get rid of it and then not need this serialize impl. It's not much overhead though, so I'm happy with this fix.

Comment on lines +38 to 47
#[derive(Debug, Clone, Serialize)]
struct FuzzTargetInput {
#[serde(skip)]
request: ABACRequest,
policy: ABACPolicy,
#[serde(skip)]
entities: Entities,
#[serde(skip)]
schema: cedar_policy_validator::ValidatorSchema,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm still interested in what this Serialize is used for, and whether we could just remove uses of Serialize for this FuzzTargetInput instead of restoring Serialize here.

If we do go this route, I'm wondering whether this Serialize implementation which serializes only the policy is going to be helpful, or just cause even more confusion for whatever is consuming it. For instance, if it's supposed to be a representation of the logged FuzzTargetInput, the fact that you only see the policy is probably going to be confusing or even deceiving while debugging a problem with a FuzzTargetInput.

Choose a reason for hiding this comment

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

I assume it's used here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can remove that code? Is it used by anything?

Choose a reason for hiding this comment

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

Nothing if you don't use --features log.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the question is whether --features log is useful if it only logs the policy and not the other inputs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I doubt the logs are useful given that they ignore most of the input. I decided to open the PR because it was taking me too long to figure where LOGFILE is being set, and how it's connected to other components (i.e., are these files being expected somewhere else?).

Copy link

@katherine-hough katherine-hough Mar 7, 2025

Choose a reason for hiding this comment

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

It's probably not useful. I assume this is used to analyze a random sample of generated inputs after the campaign completes presumably to collect statistics about what was generated or debug generation. Since policy generation depends on the other generated inputs, I imagine just having the policies wouldn't help very much with either. Long term I think there is probably way to re-implement this that doesn't depend on the generated structures implementing Serialize.

Copy link
Contributor

Choose a reason for hiding this comment

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

I concur.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't find this being used anywhere. I'm going to open a PR to delete the feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update: I've found where it's used, and looks like at least a couple targets might be using it. Don't think anyone is looking at the logged information though.

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.

4 participants