[Pkg-debile-commits] [debile-master] 84/126: add some protection to server methods

Sylvestre Ledru sylvestre at alioth.debian.org
Mon Aug 19 14:56:20 UTC 2013


This is an automated email from the git hooks/post-receive script.

sylvestre pushed a commit to branch scan-build-html
in repository debile-master.

commit 3b58b1c8ff8567be2ff2fa5b9c927eca03708d95
Author: Paul Tagliamonte <tag at pault.ag>
Date:   Tue Jun 11 22:30:09 2013 -0400

    add some protection to server methods
---
 eg/config.json |    6 ++++--
 lucy/server.py |   24 ++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/eg/config.json b/eg/config.json
index 6cae59d..0faa0a0 100644
--- a/eg/config.json
+++ b/eg/config.json
@@ -53,13 +53,15 @@
             "_id": "paultag",
             "email": "tag at pault.ag",
             "gpg": "57DC4BD33F73E0CDBA98D22AF7EBEE8EB7982329",
-            "name": "Paul R. Tagliamonte"
+            "name": "Paul R. Tagliamonte",
+            "auth": "secret"
         },
         {
             "_id": "rebuilder",
             "email": "paultag at debian.org",
             "gpg": "2EA5C67F0A37D37C64C7B5EDC0A1FC9FD80D7B69",
-            "name": "Archive Rebuilder"
+            "name": "Archive Rebuilder",
+            "auth": "secret"
         }
     ]
 }
diff --git a/lucy/server.py b/lucy/server.py
index 5862c30..075b91a 100644
--- a/lucy/server.py
+++ b/lucy/server.py
@@ -35,6 +35,25 @@ def send_failed_email(job, package, report):
     )
 
 
+def machine_method(fn):
+    def _(*args, **kwargs):
+        try:
+            get_builder_id()
+            fn(*args, **kwargs)
+        except KeyError:
+            raise Exception("You can't do that")
+    return _
+
+
+def user_method(fn):
+    def _(*args, **kwargs):
+        try:
+            get_user_id()
+            fn(*args, **kwargs)
+        except KeyError:
+            raise Exception("You can't do that")
+
+
 class LucyInterface(object):
 
     def get_source_package(self, package):
@@ -93,12 +112,14 @@ class LucyInterface(object):
 
     #
 
+    @machine_method
     def get_current_jobs(self):
         """
         Get the current job for the builder or return None.
         """
         return list(Job.assigned_jobs(get_builder_id()))
 
+    @machine_method
     def forfeit_job(self, job):
         j = Job.load(job)
         buildd = j.get_builder()
@@ -109,6 +130,7 @@ class LucyInterface(object):
         j['builder'] = None
         return j.save()
 
+    @machine_method
     def get_next_job(self, suites, arches, types):
         """
         Get an unassigned lint job from suite suites, arches arches
@@ -123,6 +145,7 @@ class LucyInterface(object):
         nj.save()
         return dict(nj)
 
+    @machine_method
     def submit_report(self, report, job, failed):
         """
         Submit a report from a run.
@@ -154,6 +177,7 @@ class LucyInterface(object):
 
         return rid
 
+    @machine_method
     def close_job(self, job):
         """
         Close a job after pushing reports / binaries up.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-debile/debile-master.git



More information about the Pkg-debile-commits mailing list