Skip to content

Commit 1051ec6

Browse files
authored
[BlackboxAudit] Only update fuzzer.source when creating a fuzzer (#5252)
The `Fuzzer.source` is the point of contact or owner of a fuzzer. When the fuzzer is created, the source is the author who uploads the fuzzer. Currently, when we edit the jobs, configuration, or upload a new version of the fuzzer, the `Fuzzer.source` updates to the person who is making that change. This was fine when the only one maintaining a fuzzer was the current owner of the fuzzer, but breaks down when making LSC type changes to our fuzzer suite. This PR changes the behavior to only set the source when creating a fuzzer and introduces a `last_edited_by` to capture the paper trail of changes. Now, if we want to change the owner we can do so in the datastore directly, and small edits to disable/enable a Fuzzer won't change the source, which is the Fuzzer's owner The user who is making the edit is also logged as part of the [fuzzer_update_message](https://github.com/google/clusterfuzz/blob/0b9e68ae390d76ae9f475165b1957ca10689f50b/src/appengine/handlers/fuzzers.py#L221). Tested this locally by creating and editing a fuzzer.
1 parent 288ea64 commit 1051ec6

4 files changed

Lines changed: 15 additions & 4 deletions

File tree

src/appengine/handlers/fuzzers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def apply_fuzzer_changes(self, fuzzer, upload_info):
186186

187187
fuzzer.jobs = jobs
188188
fuzzer.revision = fuzzer.revision + 1
189-
fuzzer.source = helpers.get_user_email()
189+
fuzzer.last_edited_by = helpers.get_user_email()
190190
fuzzer.timeout = timeout
191191
fuzzer.max_testcases = max_testcases
192192
fuzzer.result = None
@@ -254,6 +254,8 @@ def post(self):
254254
fuzzer.revision = 0
255255
fuzzer.created_at = datetime.datetime.now(tz=datetime.timezone.utc).replace(
256256
tzinfo=None)
257+
fuzzer.source = helpers.get_user_email()
258+
257259
return self.apply_fuzzer_changes(fuzzer, upload_info)
258260

259261

src/clusterfuzz/_internal/datastore/data_types.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ class Fuzzer(Model):
313313
# Fuzzer's source (for accountability).
314314
source = ndb.StringProperty()
315315

316+
# Last person to make changes to the Fuzzer code or configuration.
317+
last_edited_by = ndb.StringProperty()
318+
316319
# Testcase timeout.
317320
timeout = ndb.IntegerProperty()
318321

src/clusterfuzz/_internal/tests/appengine/handlers/fuzzers_test.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def setUp(self):
7878
'handlers.fuzzers.CreateHandler.get_upload',
7979
'handlers.fuzzers.CreateHandler.apply_fuzzer_changes',
8080
])
81+
8182
self.mock.has_access.return_value = True
8283
self.mock.get_current_user().email = 'test@user.com'
8384
self.mock.get_user_email.return_value = 'test@user.com'
@@ -108,6 +109,7 @@ def test_create_fuzzer(self):
108109
self.assertEqual(fuzzer.name, fuzzer_name)
109110
self.assertEqual(fuzzer.revision, 0)
110111
self.assertEqual(fuzzer.created_at, self.mock_time)
112+
self.assertEqual(fuzzer.source, 'test@user.com')
111113

112114

113115
@test_utils.with_cloud_emulators('datastore')
@@ -125,8 +127,8 @@ def setUp(self):
125127
'handlers.fuzzers.EditHandler._get_launcher_script',
126128
])
127129
self.mock.has_access.return_value = True
128-
self.mock.get_current_user().email = 'test@user.com'
129-
self.mock.get_user_email.return_value = 'test@user.com'
130+
self.mock.get_current_user().email = 'editor@example.com'
131+
self.mock.get_user_email.return_value = 'editor@example.com'
130132
self.mock.get_upload.return_value = storage.GcsBlobInfo(
131133
bucket='test-bucket', object_path='key', filename='file.zip', size=123)
132134

@@ -150,6 +152,7 @@ def test_update_fuzzer(self):
150152
name=fuzzer_name,
151153
jobs=[],
152154
revision=1,
155+
source='original@example.com',
153156
timeout=10,
154157
)
155158
fuzzer.put()
@@ -177,10 +180,11 @@ def test_update_fuzzer(self):
177180
'data_bundle_name': 'test_bundle',
178181
'external_contribution': True,
179182
'executable_path': 'executable',
183+
'last_edited_by': 'editor@example.com',
180184
'launcher_script': 'launcher',
181185
'jobs': [],
182186
'max_testcases': 100,
183187
'revision': 2,
184-
'source': 'test@user.com',
188+
'source': 'original@example.com',
185189
'timeout': 30,
186190
})

src/clusterfuzz/_internal/tests/core/datastore/data_types_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def test_get_config_dict(self):
3838
launcher_script='path/to/launcher',
3939
revision=3,
4040
source='author',
41+
last_edited_by='editor',
4142
)
4243

4344
config_dict = fuzzer.get_config_dict()
@@ -54,6 +55,7 @@ def test_get_config_dict(self):
5455
'launcher_script': 'path/to/launcher',
5556
'revision': 3,
5657
'source': 'author',
58+
'last_edited_by': 'editor',
5759
},
5860
config_dict,
5961
)

0 commit comments

Comments
 (0)