Merge lp:~gesha/linaro-license-protection/check-build-info-on-publishing into lp:~linaro-automation/linaro-license-protection/trunk

Proposed by Georgy Redkozubov
Status: Merged
Approved by: Paul Sokolovsky
Approved revision: 155
Merged at revision: 155
Proposed branch: lp:~gesha/linaro-license-protection/check-build-info-on-publishing
Merge into: lp:~linaro-automation/linaro-license-protection/trunk
Diff against target: 82 lines (+43/-0)
2 files modified
scripts/publish_to_snapshots.py (+12/-0)
tests/test_publish_to_snapshots.py (+31/-0)
To merge this branch: bzr merge lp:~gesha/linaro-license-protection/check-build-info-on-publishing
Reviewer Review Type Date Requested Status
Paul Sokolovsky Approve
Review via email: mp+145427@code.launchpad.net

Description of the change

This branch adds checks for BUILD-INFO.txt before publishing artifacts.
Build artifacts without proper protection with BUILD-INFO.txt shouldn't be published to prevent possible leaks.

To post a comment you must log in.
Revision history for this message
Paul Sokolovsky (pfalcon) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'scripts/publish_to_snapshots.py'
--- scripts/publish_to_snapshots.py 2013-01-01 23:57:40 +0000
+++ scripts/publish_to_snapshots.py 2013-01-29 16:12:28 +0000
@@ -15,6 +15,7 @@
15product_dir_path = 'target/product'15product_dir_path = 'target/product'
16PASS = 016PASS = 0
17FAIL = 117FAIL = 1
18buildinfo = 'BUILD-INFO.txt'
18acceptable_job_types = [19acceptable_job_types = [
19 'android',20 'android',
20 'prebuilt',21 'prebuilt',
@@ -367,6 +368,13 @@
367 print "Failed to move files destination path", target_dir_path368 print "Failed to move files destination path", target_dir_path
368 return FAIL369 return FAIL
369370
371 def check_buildinfo(self, build_dir_path):
372 buildinfo_path = os.path.join(build_dir_path, buildinfo)
373 if not os.path.exists(buildinfo_path):
374 return FAIL
375
376 return PASS
377
370378
371def main():379def main():
372 global uploads_path380 global uploads_path
@@ -387,6 +395,10 @@
387 if build_dir_path is None or target_dir_path is None:395 if build_dir_path is None or target_dir_path is None:
388 print "Problem with build/target path, move failed"396 print "Problem with build/target path, move failed"
389 return FAIL397 return FAIL
398 ret = publisher.check_buildinfo(build_dir_path)
399 if ret != PASS:
400 print "BUILD-INFO.txt is not present in artifacts being published"
401 return FAIL
390 ret = publisher.move_artifacts(args, build_dir_path, target_dir_path)402 ret = publisher.move_artifacts(args, build_dir_path, target_dir_path)
391 if ret != PASS:403 if ret != PASS:
392 print "Move Failed"404 print "Move Failed"
393405
=== modified file 'tests/test_publish_to_snapshots.py'
--- tests/test_publish_to_snapshots.py 2012-12-05 13:47:59 +0000
+++ tests/test_publish_to_snapshots.py 2013-01-29 16:12:28 +0000
@@ -11,6 +11,9 @@
11 SnapshotsPublisher,11 SnapshotsPublisher,
12 setup_parser,12 setup_parser,
13 product_dir_path,13 product_dir_path,
14 FAIL,
15 PASS,
16 buildinfo
14 )17 )
1518
1619
@@ -726,3 +729,31 @@
726 self.assertEqual(content, open(resulting_file).read())729 self.assertEqual(content, open(resulting_file).read())
727 self.assertEqual(howto_content, open(resulting_howto_file).read())730 self.assertEqual(howto_content, open(resulting_howto_file).read())
728 shutil.rmtree(source_dir)731 shutil.rmtree(source_dir)
732
733 def test_check_buildinfo(self):
734 self.publisher = SnapshotsPublisher()
735 param = self.parser.parse_args(
736 ['-t', 'prebuilt', '-j', 'precise-armhf-ubuntu-desktop',
737 '-n', '1'])
738 self.publisher.validate_args(param)
739 build_dir = '/'.join([param.job_name, str(param.build_num)])
740 build_path = os.path.join(self.uploads_path, build_dir)
741 os.makedirs(build_path)
742
743 file_name = os.path.join(build_path, buildinfo)
744 file = open(file_name, "w")
745 file.close()
746
747 self.assertEqual(PASS, self.publisher.check_buildinfo(build_dir))
748
749 def test_check_buildinfo_no_file(self):
750 self.publisher = SnapshotsPublisher()
751 param = self.parser.parse_args(
752 ['-t', 'prebuilt', '-j', 'precise-armhf-ubuntu-desktop',
753 '-n', '1'])
754 self.publisher.validate_args(param)
755 build_dir = '/'.join([param.job_name, str(param.build_num)])
756 build_path = os.path.join(self.uploads_path, build_dir)
757 os.makedirs(build_path)
758
759 self.assertEqual(FAIL, self.publisher.check_buildinfo(build_dir))

Subscribers

People subscribed via source and target branches