eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/generalFilePermissions.py

changeset 8222
5994b80b8760
parent 7923
91e843545d9a
equal deleted inserted replaced
8221:0572a215bd2f 8222:5994b80b8760
42 @param context security context object 42 @param context security context object
43 @type SecurityContext 43 @type SecurityContext
44 @param config dictionary with configuration data 44 @param config dictionary with configuration data
45 @type dict 45 @type dict
46 """ 46 """
47 if 'chmod' in context.callFunctionName: 47 if (
48 if context.callArgsCount == 2: 48 'chmod' in context.callFunctionName and
49 mode = context.getCallArgAtPosition(1) 49 context.callArgsCount == 2
50 ):
51 mode = context.getCallArgAtPosition(1)
52
53 if (
54 mode is not None and
55 isinstance(mode, int) and
56 (mode & stat.S_IWOTH or mode & stat.S_IXGRP)
57 ):
58 # world writable is an HIGH, group executable is a MEDIUM
59 if mode & stat.S_IWOTH:
60 severity = "H"
61 else:
62 severity = "M"
50 63
51 if ( 64 filename = context.getCallArgAtPosition(0)
52 mode is not None and 65 if filename is None:
53 isinstance(mode, int) and 66 filename = 'NOT PARSED'
54 (mode & stat.S_IWOTH or mode & stat.S_IXGRP) 67
55 ): 68 reportError(
56 # world writable is an HIGH, group executable is a MEDIUM 69 context.node.lineno - 1,
57 if mode & stat.S_IWOTH: 70 context.node.col_offset,
58 severity = "H" 71 "S103",
59 else: 72 severity,
60 severity = "M" 73 "H",
61 74 oct(mode),
62 filename = context.getCallArgAtPosition(0) 75 filename
63 if filename is None: 76 )
64 filename = 'NOT PARSED'
65
66 reportError(
67 context.node.lineno - 1,
68 context.node.col_offset,
69 "S103",
70 severity,
71 "H",
72 oct(mode),
73 filename
74 )

eric ide

mercurial