MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / getFileItems

Function getFileItems

lib/core/common.py:2556–2596  ·  view source on GitHub ↗

Returns newline delimited items contained inside file >>> "SELECT" in getFileItems(paths.SQL_KEYWORDS) True

(filename, commentPrefix='#', unicoded=True, lowercase=False, unique=False)

Source from the content-addressed store, hash-verified

2554 kb.commonOutputs[key].add(line)
2555
2556def getFileItems(filename, commentPrefix='#', unicoded=True, lowercase=False, unique=False):
2557 """
2558 Returns newline delimited items contained inside file
2559
2560 >>> "SELECT" in getFileItems(paths.SQL_KEYWORDS)
2561 True
2562 """
2563
2564 retVal = list() if not unique else OrderedDict()
2565
2566 if filename:
2567 filename = filename.strip('"\'')
2568
2569 checkFile(filename)
2570
2571 try:
2572 with openFile(filename, 'r', errors="ignore") if unicoded else open(filename, 'r') as f:
2573 for line in f:
2574 if commentPrefix:
2575 if line.find(commentPrefix) != -1:
2576 line = line[:line.find(commentPrefix)]
2577
2578 line = line.strip()
2579
2580 if line:
2581 if lowercase:
2582 line = line.lower()
2583
2584 if unique and line in retVal:
2585 continue
2586
2587 if unique:
2588 retVal[line] = True
2589 else:
2590 retVal.append(line)
2591 except (IOError, OSError, MemoryError) as ex:
2592 errMsg = "something went wrong while trying "
2593 errMsg += "to read the content of file '%s' ('%s')" % (filename, getSafeExString(ex))
2594 raise SqlmapSystemException(errMsg)
2595
2596 return retVal if not unique else list(retVal.keys())
2597
2598def goGoodSamaritan(prevValue, originalCharset):
2599 """

Callers 13

mainFunction · 0.90
dictionaryAttackFunction · 0.90
crackHashFileFunction · 0.90
tableExistsFunction · 0.90
columnExistsFunction · 0.90
fileExistsFunction · 0.90
_setBulkMultipleTargetsFunction · 0.90
_findPageFormsFunction · 0.90
getManualDirectoriesFunction · 0.85
fetchRandomAgentFunction · 0.85
createGithubIssueFunction · 0.85

Calls 8

OrderedDictClass · 0.90
checkFileFunction · 0.85
openFileFunction · 0.85
findMethod · 0.80
getSafeExStringFunction · 0.70
appendMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…