_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q19300 | Agenda._load_all | train | async def _load_all(self):
'''
Load all the appointments from persistent storage
'''
to_delete = []
for iden, val in self._hivedict.items():
try:
appt = _Appt.unpack(val)
if appt.iden != iden:
raise s_exc.Inconsisten... | python | {
"resource": ""
} |
q19301 | Agenda._addappt | train | def _addappt(self, iden, appt):
'''
Updates the data structures to add an appointment
'''
if appt.nexttime:
heapq.heappush(self.apptheap, appt)
self.appts[iden] = appt
if self.apptheap and self.apptheap[0] is appt:
self._wake_event.set() | python | {
"resource": ""
} |
q19302 | Agenda._storeAppt | train | async def _storeAppt(self, appt):
''' Store a single appointment '''
await self._hivedict.set(appt.iden, appt.pack()) | python | {
"resource": ""
} |
q19303 | Agenda.add | train | async def add(self, useriden, query: str, reqs, incunit=None, incvals=None):
'''
Persistently adds an appointment
Args:
query (str):
storm query to run
reqs (Union[None, Dict[TimeUnit, Union[int, Tuple[int]], List[...]):
one or more dicts ... | python | {
"resource": ""
} |
q19304 | Agenda.mod | train | async def mod(self, iden, query):
'''
Change the query of an appointment
'''
appt = self.appts.get(iden)
if appt is None:
raise s_exc.NoSuchIden()
if not query:
raise ValueError('empty query')
if self.enabled:
self.core.getSto... | python | {
"resource": ""
} |
q19305 | Agenda.delete | train | async def delete(self, iden):
'''
Delete an appointment
'''
appt = self.appts.get(iden)
if appt is None:
raise s_exc.NoSuchIden()
try:
heappos = self.apptheap.index(appt)
except ValueError:
pass # this is OK, just a non-recurr... | python | {
"resource": ""
} |
q19306 | Agenda._scheduleLoop | train | async def _scheduleLoop(self):
'''
Task loop to issue query tasks at the right times.
'''
while True:
try:
timeout = None if not self.apptheap else self.apptheap[0].nexttime - time.time()
if timeout is None or timeout >= 0.0:
... | python | {
"resource": ""
} |
q19307 | Agenda._execute | train | async def _execute(self, appt):
'''
Fire off the task to make the storm query
'''
user = self.core.auth.user(appt.useriden)
if user is None:
logger.warning('Unknown user %s in stored appointment', appt.useriden)
await self._markfailed(appt)
ret... | python | {
"resource": ""
} |
q19308 | Agenda._runJob | train | async def _runJob(self, user, appt):
'''
Actually run the storm query, updating the appropriate statistics and results
'''
count = 0
appt.isrunning = True
appt.laststarttime = time.time()
appt.startcount += 1
await self._storeAppt(appt)
with s_pro... | python | {
"resource": ""
} |
q19309 | get | train | def get(name, defval=None):
'''
Return an object from the embedded synapse data folder.
Example:
for tld in syanpse.data.get('iana.tlds'):
dostuff(tld)
NOTE: Files are named synapse/data/<name>.mpk
'''
with s_datfile.openDatFile('synapse.data/%s.mpk' % name) as fd:
... | python | {
"resource": ""
} |
q19310 | prop | train | def prop(pode, prop):
'''
Return the valu of a given property on the node.
Args:
pode (tuple): A packed node.
prop (str): Property to retrieve.
Notes:
The prop argument may be the full property name (foo:bar:baz), relative property name (:baz) , or the unadorned
propert... | python | {
"resource": ""
} |
q19311 | tags | train | def tags(pode, leaf=False):
'''
Get all the tags for a given node.
Args:
pode (tuple): A packed node.
leaf (bool): If True, only return the full tags.
Returns:
list: A list of tag strings.
'''
fulltags = [tag for tag in pode[1]['tags']]
if not leaf:
return f... | python | {
"resource": ""
} |
q19312 | tagged | train | def tagged(pode, tag):
'''
Check if a packed node has a given tag.
Args:
pode (tuple): A packed node.
tag (str): The tag to check.
Examples:
Check if a node is tagged with "woot" and dostuff if it is.
if s_node.tagged(node,'woot'):
dostuff()
No... | python | {
"resource": ""
} |
q19313 | Node.seen | train | async def seen(self, tick, source=None):
'''
Update the .seen interval and optionally a source specific seen node.
'''
await self.set('.seen', tick)
if source is not None:
seen = await self.snap.addNode('meta:seen', (source, self.ndef))
await seen.set('.s... | python | {
"resource": ""
} |
q19314 | Node.set | train | async def set(self, name, valu, init=False):
'''
Set a property on the node.
Args:
name (str): The name of the property.
valu (obj): The value of the property.
init (bool): Set to True to disable read-only enforcement
Returns:
(bool): Tru... | python | {
"resource": ""
} |
q19315 | Node._setops | train | async def _setops(self, name, valu, editatom, init=False):
'''
Generate operations to set a property on a node.
'''
prop = self.form.prop(name)
if prop is None:
if self.snap.strict:
raise s_exc.NoSuchProp(name=name)
await self.snap.warn(f... | python | {
"resource": ""
} |
q19316 | Node.get | train | def get(self, name):
'''
Return a secondary property value from the Node.
Args:
name (str): The name of a secondary property.
Returns:
(obj): The secondary property value or None.
'''
if name.startswith('#'):
return self.tags.get(name... | python | {
"resource": ""
} |
q19317 | Node.pop | train | async def pop(self, name, init=False):
'''
Remove a property from a node and return the value
'''
prop = self.form.prop(name)
if prop is None:
if self.snap.strict:
raise s_exc.NoSuchProp(name=name)
await self.snap.warn(f'No Such Property: {... | python | {
"resource": ""
} |
q19318 | Node.delTag | train | async def delTag(self, tag, init=False):
'''
Delete a tag from the node.
'''
path = s_chop.tagpath(tag)
name = '.'.join(path)
if self.isrunt:
raise s_exc.IsRuntForm(mesg='Cannot delete tags from runt nodes.',
form=self.form... | python | {
"resource": ""
} |
q19319 | Node.delete | train | async def delete(self, force=False):
'''
Delete a node from the cortex.
The following tear-down operations occur in order:
* validate that you have permissions to delete the node
* validate that you have permissions to delete all tags
* validate that there a... | python | {
"resource": ""
} |
q19320 | Type._getIndxChop | train | def _getIndxChop(self, indx):
'''
A helper method for Type subclasses to use for a simple way to truncate
indx bytes.
'''
# cut down an index value to 256 bytes...
if len(indx) <= 256:
return indx
base = indx[:248]
sufx = xxhash.xxh64(indx).di... | python | {
"resource": ""
} |
q19321 | Type.cmpr | train | def cmpr(self, val1, name, val2):
'''
Compare the two values using the given type specific comparator.
'''
ctor = self.getCmprCtor(name)
if ctor is None:
raise s_exc.NoSuchCmpr(cmpr=name, name=self.name)
norm1 = self.norm(val1)[0]
norm2 = self.norm(va... | python | {
"resource": ""
} |
q19322 | Type.norm | train | def norm(self, valu):
'''
Normalize the value for a given type.
Args:
valu (obj): The value to normalize.
Returns:
((obj,dict)): The normalized valu, info tuple.
Notes:
The info dictionary uses the following key conventions:
... | python | {
"resource": ""
} |
q19323 | Type.extend | train | def extend(self, name, opts, info):
'''
Extend this type to construct a sub-type.
Args:
name (str): The name of the new sub-type.
opts (dict): The type options for the sub-type.
info (dict): The type info for the sub-type.
Returns:
(synap... | python | {
"resource": ""
} |
q19324 | Type.clone | train | def clone(self, opts):
'''
Create a new instance of this type with the specified options.
Args:
opts (dict): The type specific options for the new instance.
'''
topt = self.opts.copy()
topt.update(opts)
return self.__class__(self.modl, self.name, self... | python | {
"resource": ""
} |
q19325 | Type.getIndxOps | train | def getIndxOps(self, valu, cmpr='='):
'''
Return a list of index operation tuples to lift values in a table.
Valid index operations include:
('eq', <indx>)
('pref', <indx>)
('range', (<minindx>, <maxindx>))
'''
func = self.indxcmpr.get(cmpr)
... | python | {
"resource": ""
} |
q19326 | Time.getTickTock | train | def getTickTock(self, vals):
'''
Get a tick, tock time pair.
Args:
vals (list): A pair of values to norm.
Returns:
(int, int): A ordered pair of integers.
'''
val0, val1 = vals
try:
_tick = self._getLiftValu(val0)
exc... | python | {
"resource": ""
} |
q19327 | unixlisten | train | async def unixlisten(path, onlink):
'''
Start an PF_UNIX server listening on the given path.
'''
info = {'path': path, 'unix': True}
async def onconn(reader, writer):
link = await Link.anit(reader, writer, info=info)
link.schedCoro(onlink(link))
return await asyncio.start_unix_se... | python | {
"resource": ""
} |
q19328 | unixconnect | train | async def unixconnect(path):
'''
Connect to a PF_UNIX server listening on the given path.
'''
reader, writer = await asyncio.open_unix_connection(path=path)
info = {'path': path, 'unix': True}
return await Link.anit(reader, writer, info=info) | python | {
"resource": ""
} |
q19329 | AstNode.sibling | train | def sibling(self, offs=1):
'''
Return sibling node by relative offset from self.
'''
indx = self.pindex + offs
if indx < 0:
return None
if indx >= len(self.parent.kids):
return None
return self.parent.kids[indx] | python | {
"resource": ""
} |
q19330 | AstNode.iterright | train | def iterright(self):
'''
Yield "rightward" siblings until None.
'''
offs = 1
while True:
sibl = self.sibling(offs)
if sibl is None:
break
yield sibl
offs += 1 | python | {
"resource": ""
} |
q19331 | executor | train | def executor(func, *args, **kwargs):
'''
Execute a non-coroutine function in the ioloop executor pool.
Args:
func: Function to execute.
*args: Args for the function.
**kwargs: Kwargs for the function.
Examples:
Execute a blocking API call in the executor pool::
... | python | {
"resource": ""
} |
q19332 | event_wait | train | async def event_wait(event: asyncio.Event, timeout=None):
'''
Wait on an an asyncio event with an optional timeout
Returns:
true if the event got set, None if timed out
'''
if timeout is None:
await event.wait()
return True
try:
await asyncio.wait_for(event.wait... | python | {
"resource": ""
} |
q19333 | ornot | train | async def ornot(func, *args, **kwargs):
'''
Calls func and awaits it if a returns a coroutine.
Note:
This is useful for implementing a function that might take a telepath proxy object or a local object, and you
must call a non-async method on that object.
This is also useful when c... | python | {
"resource": ""
} |
q19334 | hexstr | train | def hexstr(text):
'''
Ensure a string is valid hex.
Args:
text (str): String to normalize.
Examples:
Norm a few strings:
hexstr('0xff00')
hexstr('ff00')
Notes:
Will accept strings prefixed by '0x' or '0X' and remove them.
Returns:
str:... | python | {
"resource": ""
} |
q19335 | tags | train | def tags(norm):
'''
Divide a normalized tag string into hierarchical layers.
'''
# this is ugly for speed....
parts = norm.split('.')
return ['.'.join(parts[:i]) for i in range(1, len(parts) + 1)] | python | {
"resource": ""
} |
q19336 | getDynLocal | train | def getDynLocal(name):
'''
Dynamically import a python module and return a local.
Example:
cls = getDynLocal('foopkg.barmod.BlahClass')
blah = cls()
'''
if name.find('.') == -1:
return None
modname, objname = name.rsplit('.', 1)
mod = getDynMod(modname)
if mod... | python | {
"resource": ""
} |
q19337 | getDynMeth | train | def getDynMeth(name):
'''
Retrieve and return an unbound method by python path.
'''
cname, fname = name.rsplit('.', 1)
clas = getDynLocal(cname)
if clas is None:
return None
return getattr(clas, fname, None) | python | {
"resource": ""
} |
q19338 | tryDynMod | train | def tryDynMod(name):
'''
Dynamically import a python module or exception.
'''
try:
return importlib.import_module(name)
except ModuleNotFoundError:
raise s_exc.NoSuchDyn(name=name) | python | {
"resource": ""
} |
q19339 | tryDynLocal | train | def tryDynLocal(name):
'''
Dynamically import a module and return a module local or raise an exception.
'''
if name.find('.') == -1:
raise s_exc.NoSuchDyn(name=name)
modname, objname = name.rsplit('.', 1)
mod = tryDynMod(modname)
item = getattr(mod, objname, s_common.novalu)
if ... | python | {
"resource": ""
} |
q19340 | runDynTask | train | def runDynTask(task):
'''
Run a dynamic task and return the result.
Example:
foo = runDynTask( ('baz.faz.Foo', (), {} ) )
'''
func = getDynLocal(task[0])
if func is None:
raise s_exc.NoSuchFunc(name=task[0])
return func(*task[1], **task[2]) | python | {
"resource": ""
} |
q19341 | Migration.setFormName | train | async def setFormName(self, oldn, newn):
'''
Rename a form within all the layers.
'''
logger.info(f'Migrating [{oldn}] to [{newn}]')
async with self.getTempSlab():
i = 0
async for buid, valu in self.getFormTodo(oldn):
await self.editNode... | python | {
"resource": ""
} |
q19342 | Migration.editNdefProps | train | async def editNdefProps(self, oldndef, newndef):
'''
Change all props as a result of an ndef change.
'''
oldbuid = s_common.buid(oldndef)
oldname, oldvalu = oldndef
newname, newvalu = newndef
rename = newname != oldname
# we only need to update secondar... | python | {
"resource": ""
} |
q19343 | Snap.iterStormPodes | train | async def iterStormPodes(self, text, opts=None, user=None):
'''
Yield packed node tuples for the given storm query text.
'''
if user is None:
user = self.user
dorepr = False
dopath = False
self.core._logStormQuery(text, user)
if opts is not ... | python | {
"resource": ""
} |
q19344 | Snap.getNodeByBuid | train | async def getNodeByBuid(self, buid):
'''
Retrieve a node tuple by binary id.
Args:
buid (bytes): The binary ID for the node.
Returns:
Optional[s_node.Node]: The node object or None.
'''
node = self.livenodes.get(buid)
if node is not None... | python | {
"resource": ""
} |
q19345 | Snap.getNodesBy | train | async def getNodesBy(self, full, valu=None, cmpr='='):
'''
The main function for retrieving nodes by prop.
Args:
full (str): The property/tag name.
valu (obj): A lift compatible value for the type.
cmpr (str): An optional alternate comparator.
Yields... | python | {
"resource": ""
} |
q19346 | Snap.addNode | train | async def addNode(self, name, valu, props=None):
'''
Add a node by form name and value with optional props.
Args:
name (str): The form of node to add.
valu (obj): The value for the node.
props (dict): Optional secondary properties for the node.
'''
... | python | {
"resource": ""
} |
q19347 | Snap._getNodeFnib | train | def _getNodeFnib(self, name, valu):
'''
return a form, norm, info, buid tuple
'''
form = self.model.form(name)
if form is None:
raise s_exc.NoSuchForm(name=name)
try:
norm, info = form.type.norm(valu)
except Exception as e:
rai... | python | {
"resource": ""
} |
q19348 | Snap.getLiftRows | train | async def getLiftRows(self, lops):
'''
Yield row tuples from a series of lift operations.
Row tuples only requirement is that the first element
be the binary id of a node.
Args:
lops (list): A list of lift operations.
Yields:
(tuple): (layer_ind... | python | {
"resource": ""
} |
q19349 | CoreModule.getModName | train | def getModName(self):
'''
Return the lowercased name of this module.
Notes:
This pulls the ``mod_name`` attribute on the class. This allows
an implementer to set a arbitrary name for the module. If this
attribute is not set, it defaults to
``self... | python | {
"resource": ""
} |
q19350 | CoreModule.getModPath | train | def getModPath(self, *paths):
'''
Construct a path relative to this module's working directory.
Args:
*paths: A list of path strings
Notes:
This creates the module specific directory if it does not exist.
Returns:
(str): The full path (or No... | python | {
"resource": ""
} |
q19351 | ctor | train | def ctor(name, func, *args, **kwargs):
'''
Add a ctor callback to the global scope.
'''
return globscope.ctor(name, func, *args, **kwargs) | python | {
"resource": ""
} |
q19352 | Scope.get | train | def get(self, name, defval=None):
'''
Retrieve a value from the closest scope frame.
'''
for frame in reversed(self.frames):
valu = frame.get(name, s_common.novalu)
if valu != s_common.novalu:
return valu
task = self.ctors.get(name)
... | python | {
"resource": ""
} |
q19353 | Scope.ctor | train | def ctor(self, name, func, *args, **kwargs):
'''
Add a constructor to be called when a specific property is not present.
Example:
scope.ctor('foo',FooThing)
...
foo = scope.get('foo')
'''
self.ctors[name] = (func, args, kwargs) | python | {
"resource": ""
} |
q19354 | AQueue.put | train | def put(self, item):
'''
Add an item to the queue.
'''
if self.isfini:
return False
self.fifo.append(item)
if len(self.fifo) == 1:
self.event.set()
return True | python | {
"resource": ""
} |
q19355 | EditAtom.getNodeBeingMade | train | def getNodeBeingMade(self, buid):
'''
Return a node if it is currently being made, mark as a dependency, else None if none found
'''
nodeevnt = self.allbldgbuids.get(buid)
if nodeevnt is None:
return None
if buid not in self.mybldgbuids:
self.other... | python | {
"resource": ""
} |
q19356 | EditAtom.addNode | train | def addNode(self, node):
'''
Update the shared map with my in-construction node
'''
self.mybldgbuids[node.buid] = node
self.allbldgbuids[node.buid] = (node, self.doneevent) | python | {
"resource": ""
} |
q19357 | EditAtom._notifyDone | train | def _notifyDone(self):
'''
Allow any other editatoms waiting on me to complete to resume
'''
if self.notified:
return
self.doneevent.set()
for buid in self.mybldgbuids:
del self.allbldgbuids[buid]
self.notified = True | python | {
"resource": ""
} |
q19358 | EditAtom._wait | train | async def _wait(self):
'''
Wait on the other editatoms who are constructing nodes my new nodes refer to
'''
for buid in self.otherbldgbuids:
nodeevnt = self.allbldgbuids.get(buid)
if nodeevnt is None:
continue
await nodeevnt[1].wait() | python | {
"resource": ""
} |
q19359 | EditAtom.commit | train | async def commit(self, snap):
'''
Push the recorded changes to disk, notify all the listeners
'''
if not self.npvs: # nothing to do
return
for node, prop, _, valu in self.npvs:
node.props[prop.name] = valu
node.proplayr[prop.name] = snap.wlyr... | python | {
"resource": ""
} |
q19360 | getItemCmdr | train | async def getItemCmdr(cell, outp=None, **opts):
'''
Construct and return a cmdr for the given remote cell.
Example:
cmdr = await getItemCmdr(foo)
'''
cmdr = await s_cli.Cli.anit(cell, outp=outp)
typename = await cell.getCellType()
for ctor in cmdsbycell.get(typename, ()):
... | python | {
"resource": ""
} |
q19361 | runItemCmdr | train | async def runItemCmdr(item, outp=None, **opts):
'''
Create a cmdr for the given item and run the cmd loop.
Example:
runItemCmdr(foo)
'''
cmdr = await getItemCmdr(item, outp=outp, **opts)
await cmdr.runCmdLoop() | python | {
"resource": ""
} |
q19362 | getDocPath | train | def getDocPath(fn, root=None):
'''
Helper for getting a documentation data file paths.
Args:
fn (str): Name of the file to retrieve the full path for.
root (str): Optional root path to look for a docdata in.
Notes:
Defaults to looking for the ``docdata`` directory in the curren... | python | {
"resource": ""
} |
q19363 | genTempCoreProxy | train | async def genTempCoreProxy(mods=None):
'''Get a temporary cortex proxy.'''
with s_common.getTempDir() as dirn:
async with await s_cortex.Cortex.anit(dirn) as core:
if mods:
for mod in mods:
await core.loadCoreModule(mod)
async with core.getLoca... | python | {
"resource": ""
} |
q19364 | getItemCmdr | train | async def getItemCmdr(prox, outp=None, locs=None):
'''Get a Cmdr instance with prepopulated locs'''
cmdr = await s_cmdr.getItemCmdr(prox, outp=outp)
cmdr.echoline = True
if locs:
cmdr.locs.update(locs)
return cmdr | python | {
"resource": ""
} |
q19365 | getTempCoreProx | train | async def getTempCoreProx(mods=None):
'''
Get a Telepath Proxt to a Cortex instance which is backed by a temporary Cortex.
Args:
mods (list): A list of additional CoreModules to load in the Cortex.
Notes:
The Proxy returned by this should be fini()'d to tear down the temporary Cortex.
... | python | {
"resource": ""
} |
q19366 | getTempCoreCmdr | train | async def getTempCoreCmdr(mods=None, outp=None):
'''
Get a CmdrCore instance which is backed by a temporary Cortex.
Args:
mods (list): A list of additional CoreModules to load in the Cortex.
outp: A output helper. Will be used for the Cmdr instance.
Notes:
The CmdrCore returne... | python | {
"resource": ""
} |
q19367 | CmdrCore.addFeedData | train | async def addFeedData(self, name, items, seqn=None):
'''
Add feed data to the cortex.
'''
return await self.core.addFeedData(name, items, seqn) | python | {
"resource": ""
} |
q19368 | CmdrCore.storm | train | async def storm(self, text, opts=None, num=None, cmdr=False):
'''
A helper for executing a storm command and getting a list of storm messages.
Args:
text (str): Storm command to execute.
opts (dict): Opt to pass to the cortex during execution.
num (int): Numb... | python | {
"resource": ""
} |
q19369 | _inputrc_enables_vi_mode | train | def _inputrc_enables_vi_mode():
'''
Emulate a small bit of readline behavior.
Returns:
(bool) True if current user enabled vi mode ("set editing-mode vi") in .inputrc
'''
for filepath in (os.path.expanduser('~/.inputrc'), '/etc/inputrc'):
try:
with open(filepath) as f:
... | python | {
"resource": ""
} |
q19370 | Cmd.runCmdLine | train | async def runCmdLine(self, line):
'''
Run a line of command input for this command.
Args:
line (str): Line to execute
Examples:
Run the foo command with some arguments:
await foo.runCmdLine('foo --opt baz woot.com')
'''
opts = s... | python | {
"resource": ""
} |
q19371 | Cli.addSignalHandlers | train | async def addSignalHandlers(self):
'''
Register SIGINT signal handler with the ioloop to cancel the currently running cmdloop task.
'''
def sigint():
self.printf('<ctrl-c>')
if self.cmdtask is not None:
self.cmdtask.cancel()
self.loop.add... | python | {
"resource": ""
} |
q19372 | Cli.prompt | train | async def prompt(self, text=None):
'''
Prompt for user input from stdin.
'''
if self.sess is None:
hist = FileHistory(s_common.getSynPath('cmdr_history'))
self.sess = PromptSession(history=hist)
if text is None:
text = self.cmdprompt
... | python | {
"resource": ""
} |
q19373 | Cli.addCmdClass | train | def addCmdClass(self, ctor, **opts):
'''
Add a Cmd subclass to this cli.
'''
item = ctor(self, **opts)
name = item.getCmdName()
self.cmds[name] = item | python | {
"resource": ""
} |
q19374 | Cli.runCmdLine | train | async def runCmdLine(self, line):
'''
Run a single command line.
Args:
line (str): Line to execute.
Examples:
Execute the 'woot' command with the 'help' switch:
await cli.runCmdLine('woot --help')
Returns:
object: Arbitrary ... | python | {
"resource": ""
} |
q19375 | CertDir.genCaCert | train | def genCaCert(self, name, signas=None, outp=None, save=True):
'''
Generates a CA keypair.
Args:
name (str): The name of the CA keypair.
signas (str): The CA keypair to sign the new CA with.
outp (synapse.lib.output.Output): The output buffer.
Example... | python | {
"resource": ""
} |
q19376 | CertDir.genHostCert | train | def genHostCert(self, name, signas=None, outp=None, csr=None, sans=None):
'''
Generates a host keypair.
Args:
name (str): The name of the host keypair.
signas (str): The CA keypair to sign the new host keypair with.
outp (synapse.lib.output.Output): The outpu... | python | {
"resource": ""
} |
q19377 | CertDir.genUserCert | train | def genUserCert(self, name, signas=None, outp=None, csr=None):
'''
Generates a user keypair.
Args:
name (str): The name of the user keypair.
signas (str): The CA keypair to sign the new user keypair with.
outp (synapse.lib.output.Output): The output buffer.
... | python | {
"resource": ""
} |
q19378 | CertDir.valUserCert | train | def valUserCert(self, byts, cacerts=None):
'''
Validate the PEM encoded x509 user certificate bytes and return it.
Args:
byts (bytes): The bytes for the User Certificate.
cacerts (tuple): A tuple of OpenSSL.crypto.X509 CA Certificates.
Raises:
OpenSS... | python | {
"resource": ""
} |
q19379 | CertDir.getCaCerts | train | def getCaCerts(self):
'''
Return a list of CA certs from the CertDir.
Returns:
[OpenSSL.crypto.X509]: List of CA certificates.
'''
retn = []
path = s_common.genpath(self.certdir, 'cas')
for name in os.listdir(path):
if not name.endswith(... | python | {
"resource": ""
} |
q19380 | CertDir.getHostCaPath | train | def getHostCaPath(self, name):
'''
Gets the path to the CA certificate that issued a given host keypair.
Args:
name (str): The name of the host keypair.
Examples:
Get the path to the CA cert which issue the cert for "myhost":
mypath = cdir.getHo... | python | {
"resource": ""
} |
q19381 | CertDir.getHostCertPath | train | def getHostCertPath(self, name):
'''
Gets the path to a host certificate.
Args:
name (str): The name of the host keypair.
Examples:
Get the path to the host certificate for the host "myhost":
mypath = cdir.getHostCertPath('myhost')
Retu... | python | {
"resource": ""
} |
q19382 | CertDir.getUserCaPath | train | def getUserCaPath(self, name):
'''
Gets the path to the CA certificate that issued a given user keypair.
Args:
name (str): The name of the user keypair.
Examples:
Get the path to the CA cert which issue the cert for "myuser":
mypath = cdir.getUs... | python | {
"resource": ""
} |
q19383 | CertDir.getUserForHost | train | def getUserForHost(self, user, host):
'''
Gets the name of the first existing user cert for a given user and host.
Args:
user (str): The name of the user.
host (str): The name of the host.
Examples:
Get the name for the "myuser" user cert at "cool.ve... | python | {
"resource": ""
} |
q19384 | CertDir.importFile | train | def importFile(self, path, mode, outp=None):
'''
Imports certs and keys into the Synapse cert directory
Args:
path (str): The path of the file to be imported.
mode (str): The certdir subdirectory to import the file into.
Examples:
Import CA certifcia... | python | {
"resource": ""
} |
q19385 | CertDir.isCaCert | train | def isCaCert(self, name):
'''
Checks if a CA certificate exists.
Args:
name (str): The name of the CA keypair.
Examples:
Check if the CA certificate for "myca" exists:
exists = cdir.isCaCert('myca')
Returns:
bool: True if th... | python | {
"resource": ""
} |
q19386 | CertDir.isHostCert | train | def isHostCert(self, name):
'''
Checks if a host certificate exists.
Args:
name (str): The name of the host keypair.
Examples:
Check if the host cert "myhost" exists:
exists = cdir.isUserCert('myhost')
Returns:
bool: True if... | python | {
"resource": ""
} |
q19387 | CertDir.isUserCert | train | def isUserCert(self, name):
'''
Checks if a user certificate exists.
Args:
name (str): The name of the user keypair.
Examples:
Check if the user cert "myuser" exists:
exists = cdir.isUserCert('myuser')
Returns:
bool: True if... | python | {
"resource": ""
} |
q19388 | CertDir.signCertAs | train | def signCertAs(self, cert, signas):
'''
Signs a certificate with a CA keypair.
Args:
cert (OpenSSL.crypto.X509): The certificate to sign.
signas (str): The CA keypair name to sign the new keypair with.
Examples:
Sign a certificate with the CA "myca":... | python | {
"resource": ""
} |
q19389 | CertDir.signHostCsr | train | def signHostCsr(self, xcsr, signas, outp=None, sans=None):
'''
Signs a host CSR with a CA keypair.
Args:
cert (OpenSSL.crypto.X509Req): The certificate signing request.
signas (str): The CA keypair name to sign the CSR with.
outp (synapse.lib.output.Output): ... | python | {
"resource": ""
} |
q19390 | CertDir.selfSignCert | train | def selfSignCert(self, cert, pkey):
'''
Self-sign a certificate.
Args:
cert (OpenSSL.crypto.X509): The certificate to sign.
pkey (OpenSSL.crypto.PKey): The PKey with which to sign the certificate.
Examples:
Sign a given certificate with a given priva... | python | {
"resource": ""
} |
q19391 | CertDir.signUserCsr | train | def signUserCsr(self, xcsr, signas, outp=None):
'''
Signs a user CSR with a CA keypair.
Args:
cert (OpenSSL.crypto.X509Req): The certificate signing request.
signas (str): The CA keypair name to sign the CSR with.
outp (synapse.lib.output.Output): The output ... | python | {
"resource": ""
} |
q19392 | CertDir.getClientSSLContext | train | def getClientSSLContext(self):
'''
Returns an ssl.SSLContext appropriate for initiating a TLS session
'''
sslctx = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
self._loadCasIntoSSLContext(sslctx)
return sslctx | python | {
"resource": ""
} |
q19393 | CertDir.getServerSSLContext | train | def getServerSSLContext(self, hostname=None):
'''
Returns an ssl.SSLContext appropriate to listen on a socket
Args:
hostname: if None, the value from socket.gethostname is used to find the key in the servers directory.
This name should match the not-suffixed part of two... | python | {
"resource": ""
} |
q19394 | CertDir.saveCertPem | train | def saveCertPem(self, cert, path):
'''
Save a certificate in PEM format to a file outside the certdir.
'''
with s_common.genfile(path) as fd:
fd.write(crypto.dump_certificate(crypto.FILETYPE_PEM, cert)) | python | {
"resource": ""
} |
q19395 | CertDir.savePkeyPem | train | def savePkeyPem(self, pkey, path):
'''
Save a private key in PEM format to a file outside the certdir.
'''
with s_common.genfile(path) as fd:
fd.write(crypto.dump_privatekey(crypto.FILETYPE_PEM, pkey)) | python | {
"resource": ""
} |
q19396 | doECDHE | train | def doECDHE(statprv_u, statpub_v, ephmprv_u, ephmpub_v,
length=64,
salt=None,
info=None):
'''
Perform one side of an Ecliptic Curve Diffie Hellman Ephemeral key exchange.
Args:
statprv_u (PriKey): Static Private Key for U
statpub_v (PubKey: Static Public ... | python | {
"resource": ""
} |
q19397 | PriKey.sign | train | def sign(self, byts):
'''
Compute the ECC signature for the given bytestream.
Args:
byts (bytes): The bytes to sign.
Returns:
bytes: The RSA Signature bytes.
'''
chosen_hash = c_hashes.SHA256()
hasher = c_hashes.Hash(chosen_hash, default_... | python | {
"resource": ""
} |
q19398 | PriKey.exchange | train | def exchange(self, pubkey):
'''
Perform a ECDH key exchange with a public key.
Args:
pubkey (PubKey): A PubKey to perform the ECDH with.
Returns:
bytes: The ECDH bytes. This is deterministic for a given pubkey
and private key.
'''
try... | python | {
"resource": ""
} |
q19399 | PubKey.verify | train | def verify(self, byts, sign):
'''
Verify the signature for the given bytes using the ECC
public key.
Args:
byts (bytes): The data bytes.
sign (bytes): The signature bytes.
Returns:
bool: True if the data was verified, False otherwise.
... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.