Skip to content

DSL for FuzzConfig#23

Merged
AbdullinAM merged 15 commits intomainfrom
ilma4/config-dsl
Jan 22, 2025
Merged

DSL for FuzzConfig#23
AbdullinAM merged 15 commits intomainfrom
ilma4/config-dsl

Conversation

@ilma4
Copy link
Contributor

@ilma4 ilma4 commented Jan 15, 2025

No description provided.

val fuzzEngine: String = FUZZ_ENGINE_DEFAULT,
val hooks: Boolean = HOOKS_DEFAULT,
val keepGoing: Int = KEEP_GOING_DEFAULT,
val instrument: List<String>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we want to specialise instrument why not use an empty list by default?

Copy link
Contributor Author

@ilma4 ilma4 Jan 15, 2025

Choose a reason for hiding this comment

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

Because, without instrumentation jazzer (and other coverage-guided fuzzers) doesn't work properly. So, I believe, it's better to explicitly ask user to set it to empty list.

Idealy, we could deduct the instrument automatically. In that case, we should let the user not to specify it. I believe, we'll do it later.

@ilma4 ilma4 requested a review from FerrumBrain January 15, 2025 16:01
FerrumBrain
FerrumBrain previously approved these changes Jan 15, 2025
Copy link
Contributor

@FerrumBrain FerrumBrain 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 to me, however I would wait for approval from Denis

@AbdullinAM AbdullinAM added the ready for review PR is ready to be reviewed label Jan 16, 2025
@ilma4 ilma4 added in progress PR is not ready to be reviewed and removed ready for review PR is ready to be reviewed labels Jan 20, 2025
@ilma4 ilma4 added ready for review PR is ready to be reviewed and removed in progress PR is not ready to be reviewed labels Jan 20, 2025
@ilma4 ilma4 requested a review from FerrumBrain January 20, 2025 12:48
@ilma4 ilma4 requested a review from DLochmelis33 January 21, 2025 13:09
AbdullinAM
AbdullinAM previously approved these changes Jan 22, 2025
Copy link
Member

@AbdullinAM AbdullinAM left a comment

Choose a reason for hiding this comment

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

Overall everything looks good. But I think maybe we should first resolve and merge #26. Then we will be able to merge this and ensure that everything is consistent

# Conflicts:
#	kotlinx.fuzz.api/build.gradle.kts
Copy link
Contributor

@DLochmelis33 DLochmelis33 left a comment

Choose a reason for hiding this comment

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

I have one major question: why did you decide to ditch a simple interface with methods like storeAsSystemProperties() / loadFromSystemProperties()? (even though I agree that custom delegates are cool 😎 )

val toString: (T) -> String,
val fromString: (String) -> T,
) : ReadWriteProperty<Any, T> {
private var cachedValue: T? = null
Copy link
Contributor

Choose a reason for hiding this comment

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

by lazy { ... } ?

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 not because of writes, but see my next comment before resolving this

error("Property '${property.name}' is already set")
}
cachedValue = value
}
Copy link
Contributor

Choose a reason for hiding this comment

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

To be honest, the logic seems unnecessarily complicated to me. When we read a property, we will have lazy init from system properties, but when we write a property, we won't write them into system, so we need to do an explicit dump of our config, but not an explicit load. But wait, we have fromSystemProperties(), so we actually do need to do an explicit load? And I don't see a method for explicit write to system properties, which I just said we should do?... I'm confused 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's complicated. More on it here

fuzzEngine = "twice"
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

do we also need to test whether the config is properly stored and loaded from system properties? (because right now I'm not even sure how to do it...)

@ilma4
Copy link
Contributor Author

ilma4 commented Jan 22, 2025

@DLochmelis33

I have one major question: why did you decide to ditch a simple interface with methods like storeAsSystemProperties() / loadFromSystemProperties()? (even though I agree that custom delegates are cool 😎 )

I didn't do storeAsSystemProperties because we need to write properties in our gradle plugin which is different from writing them in regular kotlin/java code.

Regarding general complexity: the main idea was to make sure DSL is always correct with the minimal effort.

In the end, there is only 2 ways to get a KFuzzConfig instance: KFuzz...Impl.build or fromSystemProperties. The build checks if user has set all required options and fromSystemProperties if all options are specified in system properties. This is where reading complexity comes from.

@DLochmelis33
Copy link
Contributor

Regarding general complexity: the main idea was to make sure DSL is always correct with the minimal effort.

I guess that from the user's POV this is the only thing that matters, and we will only need to use it in the code one time. My only concern is that this code has a bus factor of 1 👀 but it's not particularly complicated, so it should be fine.

@ilma4
Copy link
Contributor Author

ilma4 commented Jan 22, 2025

@DLochmelis33
I've taken your comments into account. Now KFuzzConfigProperty is set explicitly either by user in the build block or in fromSystemProperties by calling setFromSystemProperty

@AbdullinAM AbdullinAM merged commit 304ae44 into main Jan 22, 2025
4 checks passed
@AbdullinAM AbdullinAM deleted the ilma4/config-dsl branch January 22, 2025 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review PR is ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants