当前位置: 首页>>代码示例>>Python>>正文


Python ProtectedRef.update方法代码示例

本文整理汇总了Python中fast.ProtectedRef.ProtectedRef.update方法的典型用法代码示例。如果您正苦于以下问题:Python ProtectedRef.update方法的具体用法?Python ProtectedRef.update怎么用?Python ProtectedRef.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fast.ProtectedRef.ProtectedRef的用法示例。


在下文中一共展示了ProtectedRef.update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_not_tracking_implicit_flows

# 需要导入模块: from fast.ProtectedRef import ProtectedRef [as 别名]
# 或者: from fast.ProtectedRef.ProtectedRef import update [as 别名]
	def test_not_tracking_implicit_flows(self):
		x = ProtectedRef(0, None, self.allowUserWrite(self.aliceUser), False)
		x.update(self.aliceUser, self.aliceUser, 42)
		y = ProtectedRef(1, None, self.allowUserWrite(self.bobUser), False)
		y.update(self.bobUser, self.bobUser, 2 if x.v == 42 else 3)
		self.assertEqual(JeevesLib.concretize(self.aliceUser, y.v), 2)
		self.assertEqual(JeevesLib.concretize(self.bobUser, y.v), 2)
开发者ID:Ch0c0late,项目名称:jeeves,代码行数:9,代码来源:testJeevesWrite.py

示例2: test_determine_writer_trust_later

# 需要导入模块: from fast.ProtectedRef import ProtectedRef [as 别名]
# 或者: from fast.ProtectedRef.ProtectedRef import update [as 别名]
	def test_determine_writer_trust_later(self):
		x = ProtectedRef(0, None
					, lambda _this: lambda ictxt: lambda octxt:
							JeevesLib.jhas(octxt, ictxt))
		x.update(self.aliceUser, self.aliceUser, 42)
		self.assertEqual(JeevesLib.concretize([self.aliceUser], x.v), 42)
		self.assertEqual(JeevesLib.concretize([], x.v), 0)
开发者ID:Ch0c0late,项目名称:jeeves,代码行数:9,代码来源:testJeevesWrite.py

示例3: test_permitted_writer_overwrite

# 需要导入模块: from fast.ProtectedRef import ProtectedRef [as 别名]
# 或者: from fast.ProtectedRef.ProtectedRef import update [as 别名]
	def test_permitted_writer_overwrite(self):	
		x = ProtectedRef(0, None, self.allowUserWrite(self.bobUser))
		assert x.update(self.aliceUser, self.aliceUser, 42) == UpdateResult.Unknown
		assert x.update(self.bobUser, self.bobUser, 43) == UpdateResult.Unknown
		self.assertEqual(JeevesLib.concretize(self.aliceUser, x.v), 43)
		self.assertEqual(JeevesLib.concretize(self.bobUser, x.v), 43)
		self.assertEqual(JeevesLib.concretize(self.carolUser, x.v), 43)
开发者ID:Ch0c0late,项目名称:jeeves,代码行数:9,代码来源:testJeevesWrite.py

示例4: test_prevent_untrusted_writes_through_implicit_flows

# 需要导入模块: from fast.ProtectedRef import ProtectedRef [as 别名]
# 或者: from fast.ProtectedRef.ProtectedRef import update [as 别名]
	def test_prevent_untrusted_writes_through_implicit_flows(self):
		x = ProtectedRef(0, None, self.allowUserWrite(self.aliceUser))
		x.update(self.aliceUser, self.aliceUser, 42)
		y = ProtectedRef(1, None, self.allowUserWrite(self.bobUser))
		y.update(self.bobUser, self.bobUser, 2 if x.v == 42 else 3)
		self.assertEqual(JeevesLib.concretize(self.aliceUser, y.v), 3)
		self.assertEqual(JeevesLib.concretize(self.bobUser, y.v), 3)
开发者ID:Ch0c0late,项目名称:jeeves,代码行数:9,代码来源:testJeevesWrite.py

示例5: test_output_write_policies_involving_this_can_update

# 需要导入模块: from fast.ProtectedRef import ProtectedRef [as 别名]
# 或者: from fast.ProtectedRef.ProtectedRef import update [as 别名]
 def test_output_write_policies_involving_this_can_update(self):
   x = ProtectedRef(0, None
         , lambda v: lambda ictxt: lambda _:
             v == 0 and ictxt == self.aliceUser)
   x.update(self.aliceUser, self.aliceUser, 1)
   self.assertEqual(JeevesLib.concretize(self.aliceUser, x.v), 1)
   x.update(self.aliceUser, self.aliceUser, 3)
   self.assertEqual(JeevesLib.concretize(self.aliceUser, x.v), 1)
开发者ID:labdalla,项目名称:jeeves,代码行数:10,代码来源:testJeevesWrite.py

示例6: test_output_varies_depending_on_viewer

# 需要导入模块: from fast.ProtectedRef import ProtectedRef [as 别名]
# 或者: from fast.ProtectedRef.ProtectedRef import update [as 别名]
	def test_output_varies_depending_on_viewer(self):
		x = ProtectedRef(0, None
					, lambda _this: lambda ictxt: lambda octxt:
							ictxt == self.aliceUser and octxt == self.bobUser)
		x.update(self.aliceUser, self.aliceUser, 42)
		self.assertEqual(JeevesLib.concretize(self.aliceUser, x.v), 0)
		self.assertEqual(JeevesLib.concretize(self.bobUser, x.v), 42)
		self.assertEqual(JeevesLib.concretize(self.carolUser, x.v), 0)
开发者ID:Ch0c0late,项目名称:jeeves,代码行数:10,代码来源:testJeevesWrite.py

示例7: test_prevent_flow_of_untrusted_writes

# 需要导入模块: from fast.ProtectedRef import ProtectedRef [as 别名]
# 或者: from fast.ProtectedRef.ProtectedRef import update [as 别名]
	def test_prevent_flow_of_untrusted_writes(self):
		x = ProtectedRef(0, None, self.allowUserWrite(self.aliceUser))
		assert x.update(self.aliceUser, self.aliceUser, 42) == UpdateResult.Unknown
		y = ProtectedRef(1, None, self.allowUserWrite(self.bobUser))
		assert y.update(self.bobUser, self.bobUser, x.v) == UpdateResult.Unknown
		self.assertEqual(JeevesLib.concretize(self.aliceUser, x.v), 42)
		self.assertEqual(JeevesLib.concretize(self.bobUser, x.v), 42)
		self.assertEqual(JeevesLib.concretize(self.aliceUser, y.v), 0)
		self.assertEqual(JeevesLib.concretize(self.bobUser, y.v), 0)	 
开发者ID:Ch0c0late,项目名称:jeeves,代码行数:11,代码来源:testJeevesWrite.py

示例8: test_function_facets_cannot_write

# 需要导入模块: from fast.ProtectedRef import ProtectedRef [as 别名]
# 或者: from fast.ProtectedRef.ProtectedRef import update [as 别名]
	def test_function_facets_cannot_write(self):
		def id(x):
			return x
		def inc(x):
			return x+1
		x = ProtectedRef(id, None, self.allowUserWrite(self.bobUser))
		self.assertEqual(JeevesLib.concretize(self.aliceUser, x.v)(1), 1)
		x.update(self.aliceUser, self.aliceUser, inc)
		self.assertEqual(JeevesLib.concretize(self.aliceUser, x.v)(1), 1)
开发者ID:Ch0c0late,项目名称:jeeves,代码行数:11,代码来源:testJeevesWrite.py

示例9: test_combining_write_policies_in_operation

# 需要导入模块: from fast.ProtectedRef import ProtectedRef [as 别名]
# 或者: from fast.ProtectedRef.ProtectedRef import update [as 别名]
	def test_combining_write_policies_in_operation(self):
		x = ProtectedRef(0, None, self.allowUserWrite(self.bobUser))
		x.update(self.bobUser, self.bobUser, 42)
		y = ProtectedRef(2, None
			, lambda _this: lambda ictxt: lambda octxt:
					ictxt == self.aliceUser and octxt == self.bobUser)
		y.update(self.aliceUser, self.aliceUser, 43)
		self.assertEqual(JeevesLib.concretize(self.aliceUser, x.v + y.v), 44)
		self.assertEqual(JeevesLib.concretize(self.bobUser, x.v + y.v), 85)
		self.assertEqual(JeevesLib.concretize(self.carolUser, x.v + y.v), 44)
开发者ID:Ch0c0late,项目名称:jeeves,代码行数:12,代码来源:testJeevesWrite.py

示例10: test_prevent_implicit_flows_of_confidential_values

# 需要导入模块: from fast.ProtectedRef import ProtectedRef [as 别名]
# 或者: from fast.ProtectedRef.ProtectedRef import update [as 别名]
 def test_prevent_implicit_flows_of_confidential_values(self):
   x = ProtectedRef(0, None
         , lambda _this: lambda ictxt: lambda octxt:
             ictxt == self.aliceUser and octxt == self.aliceUser)
   x.update(self.aliceUser, self.aliceUser, 42)
   y = ProtectedRef(1, None
         , lambda _this: lambda ictxt: lambda octxt:
             ictxt == self.bobUser or ictxt == self.aliceUser)
   y.update(self.bobUser, self.bobUser, 2 if x.v == 42 else 3)
   self.assertEqual(JeevesLib.concretize(self.aliceUser, y.v), 2)
   self.assertEqual(JeevesLib.concretize(self.bobUser, y.v), 3)
开发者ID:CrossTheStreams,项目名称:jeeves,代码行数:13,代码来源:testJeevesWrite.py

示例11: test_prevent_implicit_flows_of_confidential_values

# 需要导入模块: from fast.ProtectedRef import ProtectedRef [as 别名]
# 或者: from fast.ProtectedRef.ProtectedRef import update [as 别名]
	def test_prevent_implicit_flows_of_confidential_values(self):
		# Alice may write to x. Only Alice may see the updates.
		x = ProtectedRef(0, None
					, lambda _this: lambda ictxt: lambda octxt:
							ictxt == self.aliceUser and octxt == self.aliceUser)
		x.update(self.aliceUser, self.aliceUser, 42)
		# Alice and Bob may both write to y.
		y = ProtectedRef(1, None
					, lambda _this: lambda ictxt: lambda octxt:
							ictxt == self.bobUser or ictxt == self.aliceUser)
		y.update(self.bobUser, self.bobUser, 2 if x.v == 42 else 3)
		# self.assertEqual(JeevesLib.concretize(self.aliceUser, y.v), 2)
		self.assertEqual(JeevesLib.concretize(self.bobUser, y.v), 3)
开发者ID:Ch0c0late,项目名称:jeeves,代码行数:15,代码来源:testJeevesWrite.py

示例12: __init__

# 需要导入模块: from fast.ProtectedRef import ProtectedRef [as 别名]
# 或者: from fast.ProtectedRef.ProtectedRef import update [as 别名]
class Square:
  @jeeves
  def __init__(self, owner):
    self.owner = owner
    self.shipRef = ProtectedRef(NoShip()
      # Policy for updating: must be owner and there can't be a ship there
      # already.
      , lambda ship: lambda ic: ship == NoShip()
      , lambda ship: lambda ic: lambda _oc: self.isOwner(ic))
    self.hasBombRef = ProtectedRef(None
      , lambda _bomb: lambda ic: True
      , lambda _bomb: lambda ic: lambda _oc:
          self.hasTurn(ic) and self.allShipsPlaced(ic) and
            (not self.gameOver(ic)))

  def isOwner(self, ctxt):
    return ctxt.user == self.owner
  # TODO: Make sure function applications get applied correctly here.
  # Do we need another @jeeves annotation?
  def hasTurn(self, ctxt):
    return ctxt.game.hasTurn(ctxt.user)
  def allShipsPlaced(self, ctxt):
    return ctxt.game.allShipsPlaced()
  def gameOver(self, ctxt):
    return ctxt.game.gameOver()
  @jeeves
  def mkShipSecret(self, ship):
    a = JeevesLib.mkLabel("ship")
    JeevesLib.restrict(a
      , lambda ctxt:
          self.hasBomb() or self.isOwner(ctxt) or self.gameOver(ctxt));
    return JeevesLib.mkSensitive(a, ship, NoShip())

  # Returns whether updating a square's ship reference succeeded.
  def updateShip(self, ctxt, ship):
    return self.shipRef.update(ctxt, ctxt, self.mkShipSecret(ship)) == UpdateResult.Success
  def hasShip(self):
    return not self.shipRef.v == NoShip()
  def getShip(self):
    return self.shipRef.v

  def bomb(self, ctxt, bomb):
    return self.hasBombRef.update(ctxt, ctxt, bomb) == UpdateResult.Success
  
  def hasBomb(self):
    return not (self.hasBombRef.v == None)
开发者ID:labdalla,项目名称:jeeves,代码行数:48,代码来源:Square.py

示例13: test_write_selectively_allowed

# 需要导入模块: from fast.ProtectedRef import ProtectedRef [as 别名]
# 或者: from fast.ProtectedRef.ProtectedRef import update [as 别名]
	def test_write_selectively_allowed(self):
		x = ProtectedRef(0, None
					, lambda _this: lambda ictxt: lambda octxt:
							ictxt == self.aliceUser and octxt == self.bobUser)
		assert x.update(self.aliceUser, self.aliceUser, 42) == UpdateResult.Unknown
		self.assertEqual(JeevesLib.concretize(self.aliceUser, x.v), 0)
		self.assertEqual(JeevesLib.concretize(self.bobUser, x.v), 42)
		self.assertEqual(JeevesLib.concretize(self.carolUser, x.v), 0)
开发者ID:Ch0c0late,项目名称:jeeves,代码行数:10,代码来源:testJeevesWrite.py

示例14: __init__

# 需要导入模块: from fast.ProtectedRef import ProtectedRef [as 别名]
# 或者: from fast.ProtectedRef.ProtectedRef import update [as 别名]
class Protein:
  # TODO: Figure out what kinds of policies should go here...
  def __init__(self, name, initValue=0):
    self.name = name
    self._vRef = ProtectedRef(initValue
      # We also support policies where the write checks get concretized right
      # away in the context of the user.
      , None
      # Flow is only permitted if there is an edge.
      # The policy takes the current value (v), the input channel (ic), and
      # the output channel.
      , lambda v: lambda ic: lambda oc:
          JeevesLib.jhasElt(self.edges, lambda edge: edge.v == oc))
    self._edges = []
  def addEdge(self, node, edgeType):
    self._edges.append(Edge(node, edgeType))
  def updateValue(self, ictxt, f):
    self._vRef.update(ictxt, ictxt, f(self._vRef.v))
开发者ID:Ch0c0late,项目名称:jeeves,代码行数:20,代码来源:Chemotaxis.py

示例15: testBehavioralGood

# 需要导入模块: from fast.ProtectedRef import ProtectedRef [as 别名]
# 或者: from fast.ProtectedRef.ProtectedRef import update [as 别名]
 def testBehavioralGood(self):
   touchedBadData = False
   def f(x):
     return x+1
   x = ProtectedRef(lambda x: x, None
     , lambda _this: lambda ic: lambda touchedBad: not touchedBad)
   self.assertEqual(JeevesLib.concretize(None, (x.v)(1)), 1)
   assert x.update(None, None, f) == UpdateResult.Unknown
   self.assertEqual(JeevesLib.concretize(None, (x.v)(1)), 2)
开发者ID:Ch0c0late,项目名称:jeeves,代码行数:11,代码来源:testFunctions.py


注:本文中的fast.ProtectedRef.ProtectedRef.update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。