Merge command line options with configuration file and default options. @param inputOptions: optparse object with command line options. @type inputOptions: C{instance}
(inputOptions, overrideOptions)
| 2376 | inputOptions[key] = value |
| 2377 | |
| 2378 | def _mergeOptions(inputOptions, overrideOptions): |
| 2379 | """ |
| 2380 | Merge command line options with configuration file and default options. |
| 2381 | |
| 2382 | @param inputOptions: optparse object with command line options. |
| 2383 | @type inputOptions: C{instance} |
| 2384 | """ |
| 2385 | |
| 2386 | if inputOptions.configFile: |
| 2387 | configFileParser(inputOptions.configFile) |
| 2388 | |
| 2389 | if hasattr(inputOptions, "items"): |
| 2390 | inputOptionsItems = inputOptions.items() |
| 2391 | else: |
| 2392 | inputOptionsItems = inputOptions.__dict__.items() |
| 2393 | |
| 2394 | for key, value in inputOptionsItems: |
| 2395 | if key not in conf or value not in (None, False) or overrideOptions: |
| 2396 | conf[key] = value |
| 2397 | |
| 2398 | if not conf.api: |
| 2399 | for key, value in conf.items(): |
| 2400 | if value is not None: |
| 2401 | kb.explicitSettings.add(key) |
| 2402 | |
| 2403 | for key, value in defaults.items(): |
| 2404 | if hasattr(conf, key) and conf[key] is None: |
| 2405 | conf[key] = value |
| 2406 | |
| 2407 | if conf.unstable: |
| 2408 | if key in ("timeSec", "retries", "timeout"): |
| 2409 | conf[key] *= 2 |
| 2410 | |
| 2411 | if conf.unstable: |
| 2412 | conf.forcePartial = True |
| 2413 | |
| 2414 | lut = {} |
| 2415 | for group in optDict.keys(): |
| 2416 | lut.update((_.upper(), _) for _ in optDict[group]) |
| 2417 | |
| 2418 | envOptions = {} |
| 2419 | for key, value in os.environ.items(): |
| 2420 | if key.upper().startswith(SQLMAP_ENVIRONMENT_PREFIX): |
| 2421 | _ = key[len(SQLMAP_ENVIRONMENT_PREFIX):].upper() |
| 2422 | if _ in lut: |
| 2423 | envOptions[lut[_]] = value |
| 2424 | |
| 2425 | if envOptions: |
| 2426 | _normalizeOptions(envOptions) |
| 2427 | for key, value in envOptions.items(): |
| 2428 | conf[key] = value |
| 2429 | |
| 2430 | mergedOptions.update(conf) |
| 2431 | |
| 2432 | def _setTrafficOutputFP(): |
| 2433 | if conf.trafficFile: |
no test coverage detected
searching dependent graphs…