# eric7.Plugins.CheckerPlugins.CodeStyleChecker.Security.SecurityContext

Module implementing a context class for security related checks.

### Global Attributes

None

### Classes

SecurityContext | Class implementing a context class for security related checks.

### Functions

None

## SecurityContext

Class implementing a context class for security related checks.

### Derived from

None

### Class Attributes

None

### Class Methods

None

### Methods

SecurityContext | Constructor
__getLiteralValue | Private method to turn AST literals into native Python types.
__repr__ | Special method to generate representation of object for printing or interactive use.
bytesVal | Public method to get the value of a standalone bytes object.
callArgs | Public method to get a list of function args.
callArgsCount | Public method to get the number of args a function call has.
callFunctionName | Public method to get the name (not FQ) of a function call.
callFunctionNameQual | Public method to get the FQ name of a function call.
callKeywords | Public method to get a dictionary of keyword parameters.
checkCallArgValue | Public method to check for a value of a named argument in a function call.
fileData | Public method to get the file contents.
filename | Public method to get the file name.
functionDefDefaultsQual | Public method to get a list of fully qualified default values in a function def.
getCallArgAtPosition | Public method to get a positional argument at the specified position (if it exists).
getCallArgValue | Public method to get the value of a named argument in a function call.
getLinenoForCallArg | Public method to get the line number for a specific named argument.
getOffsetForCallArg | Public method to get the offset for a specific named argument.
isModuleBeingImported | Public method to check for the given module is currently being imported.
isModuleImportedExact | Public method to check if a given module has been imported; only exact matches.
isModuleImportedLike | Public method to check if a given module has been imported; given module exists.
node | Public method to get the raw AST node associated with the context.
statement | Public method to get the raw AST for the current statement.
stringVal | Public method to get the value of a standalone string object.
stringValAsEscapedBytes | Public method to get the escaped value of the object.

### Static Methods

None

#### SecurityContext (Constructor)

SecurityContext(contextObject=None)

Constructor

Initialize the class with a context dictionary or an empty dictionary.

contextObject (dict)
  context dictionary to be used to populate the class

#### SecurityContext.__getLiteralValue

__getLiteralValue(literal)

Private method to turn AST literals into native Python types.

literal (ast.AST)
  AST literal to be converted

Return:
  converted Python object

Return Type:
  Any

#### SecurityContext.__repr__

__repr__()

Special method to generate representation of object for printing or interactive use.

Return:
  string representation of the object

Return Type:
  str

#### SecurityContext.bytesVal

bytesVal()

Public method to get the value of a standalone bytes object.

Return:
  value of a standalone bytes object

Return Type:
  bytes

#### SecurityContext.callArgs

callArgs()

Public method to get a list of function args.

Return:
  list of function args

Return Type:
  list

#### SecurityContext.callArgsCount

callArgsCount()

Public method to get the number of args a function call has.

Return:
  number of args a function call has

Return Type:
  int

#### SecurityContext.callFunctionName

callFunctionName()

Public method to get the name (not FQ) of a function call.

Return:
  name (not FQ) of a function call

Return Type:
  str

#### SecurityContext.callFunctionNameQual

callFunctionNameQual()

Public method to get the FQ name of a function call.

Return:
  FQ name of a function call

Return Type:
  str

#### SecurityContext.callKeywords

callKeywords()

Public method to get a dictionary of keyword parameters.

Return:
  dictionary of keyword parameters

Return Type:
  dict

#### SecurityContext.checkCallArgValue

checkCallArgValue(argumentName, argumentValues=None)

Public method to check for a value of a named argument in a function call.

argumentName (str)
  name of the argument to be checked
argumentValues (Any or list of Any)
  value or list of values to test against

Return:
  True if argument found and matched, False if found and not matched, None if argument not found at all

Return Type:
  bool or None

#### SecurityContext.fileData

fileData()

Public method to get the file contents.

Return:
  file contents

Return Type:
  str

#### SecurityContext.filename

filename()

Public method to get the file name.

Return:
  file name

Return Type:
  str

#### SecurityContext.functionDefDefaultsQual

functionDefDefaultsQual()

Public method to get a list of fully qualified default values in a function def.

Return:
  list of fully qualified default values in a function def

Return Type:
  list

#### SecurityContext.getCallArgAtPosition

getCallArgAtPosition(positionNum)

Public method to get a positional argument at the specified position (if it exists).

positionNum (int)
  index of the argument to get the value for

Return:
  value of the argument at the specified position if it exists

Return Type:
  Any or None

#### SecurityContext.getCallArgValue

getCallArgValue(argumentName)

Public method to get the value of a named argument in a function call.

argumentName (str)
  name of the argument to get the value for

Return:
  value of the named argument

Return Type:
  Any

#### SecurityContext.getLinenoForCallArg

getLinenoForCallArg(argumentName)

Public method to get the line number for a specific named argument.

argumentName (str)
  name of the argument to get the line number for

Return:
  line number of the found argument or -1

Return Type:
  int

#### SecurityContext.getOffsetForCallArg

getOffsetForCallArg(argumentName)

Public method to get the offset for a specific named argument.

argumentName (str)
  name of the argument to get the column offset for

Return:
  offset of the found argument or -1

Return Type:
  int

#### SecurityContext.isModuleBeingImported

isModuleBeingImported(module)

Public method to check for the given module is currently being imported.

module (str)
  module name to look for

Return:
  flag indicating the given module was found

Return Type:
  bool

#### SecurityContext.isModuleImportedExact

isModuleImportedExact(module)

Public method to check if a given module has been imported; only exact matches.

module (str)
  module name to look for

Return:
  flag indicating the given module was found

Return Type:
  bool

#### SecurityContext.isModuleImportedLike

isModuleImportedLike(module)

Public method to check if a given module has been imported; given module exists.

module (str)
  module name to look for

Return:
  flag indicating the given module was found

Return Type:
  bool

#### SecurityContext.node

node()

Public method to get the raw AST node associated with the context.

Return:
  raw AST node associated with the context

Return Type:
  ast.AST

#### SecurityContext.statement

statement()

Public method to get the raw AST for the current statement.

Return:
  raw AST for the current statement

Return Type:
  ast.AST

#### SecurityContext.stringVal

stringVal()

Public method to get the value of a standalone string object.

Return:
  value of a standalone string object

Return Type:
  str

#### SecurityContext.stringValAsEscapedBytes

stringValAsEscapedBytes()

Public method to get the escaped value of the object.

Turn the value of a string or bytes object into a byte sequence with unknown, control, and \\ characters escaped.

This function should be used when looking for a known sequence in a potentially badly encoded string in the code.

Return:
  sequence of printable ascii bytes representing original string

Return Type:
  str

Up