what does ``quiet`` argument do in scapy? - scapy

from scapy.all import *
sniff(count=2, prn=lambda x:x.sprintf("%IP.src%"), quiet=True)
The documentation says :
quiet: when set to True, the process stderr is discarded
What does this mean ?

Related

Python logging with dictConfig and using GMT / UTC zone time

I'm trying to configure some logging across multiple modules within a package. These modules may be executed in different containers, possibly in different regions, so I wanted to explicitly use GMT / UTC time for logging.
When I'm reading about the Formatter class in logging, it indicates you can specify converter to use either local-time or GMT. I'd like to utilize this feature, in conjunction with dictConfig (or possibly fileConfig) to specify the configurations for the different modules, but the documentation is sparse with respect to this feature. Everything specified in the config is working, except for the timezone. The log always uses local time. I can include the '%z' formatting specification in datefmt to specify offset from GMT, but that breaks the .%(msecs)03d formatting.
Below is my code using a defined dictionary and dictConfig. Has anyone had any success specifying timezone in the config? is this possible?
import json
import logging
from logging.config import dictConfig
import time
DEFAULT_CONFIG = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'standard': {
'format': '%(levelname)s : %(name)s : %(asctime)s.%(msecs)03d : %(message)s',
'datefmt': '%Y-%m-%d %H.%M.%S',
'converter': time.gmtime # also fails with 'time.gmtime', 'gmtime'
}
},
'handlers' : {
'default': {
'level': 'NOTSET',
'class': 'logging.StreamHandler',
'formatter': 'standard',
}
},
'loggers': {
'TEST': { # logging from this module should be logged in DEBUG level
'handlers' : ['default'],
'level': 'INFO',
'propagate': False,
},
},
'root': {
'level': 'INFO',
'handlers': ['default']
},
'incremental': False
}
if __name__ == '__main__':
dictConfig(DEFAULT_CONFIG)
logger = logging.getLogger('TEST')
logger.debug('debug message') # this should not be displayed if level==INFO
logger.info('info message')
logger.warning('warning message')
logger.error('error message')
Output:
INFO : TEST : 2022-07-07 17.20.13.434 : info message
WARNING : TEST : 2022-07-07 17.20.13.435 : warning message
ERROR : TEST : 2022-07-07 17.20.13.435 : error message

How to access json file imported into Angular

I am importing a json file via:
import * as menuJson from './menu.json';
If console.log menuJson I get:
If I try to console.log menuJson.default I get:
The error is:
Property 'default' does not exist on type
How can I turn turn this back into regular json and not a module so I can access the json content?
If your Typescript version is 2.9+, you can Do the followings:
Add these to your compilerOptions in tsconfig.json file:
"resolveJsonModule": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true
and import your json:
import menu from './menu.json';

Suppressing nightwatchjs warnings in terminal output

I'm using nightwatchjs to run my test suite, and I would like to remove the warning messages being outputted to my terminal display.
At the moment, I'm getting loads of these (admittedly genuine) warning messages whilst my scripts are running and it's making the reading of the results harder and harder.
As an example;
Yes they are valid messages, but it's not often possible for me to uniquely pick out each individual element and I'm not interested in them for my output.
So, I'd like to know how I can stop them from being reported in my terminal.
Below is what I've tried so far in my nightwatch.conf.js config file;
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled : true,
acceptSslCerts: true,
acceptInscureCerts: true,
chromeOptions : {
args: [
'--ignore-certificate-errors',
'--allow-running-insecure-content',
'--disable-web-security',
'--disable-infobars',
'--disable-popup-blocking',
'--disable-notifications',
'--log-level=3'],
prefs: {
'profile.managed_default_content_settings.popups' : 1,
'profile.managed_default_content_settings.notifications' : 1
},
},
},
},
but it's still displaying the warnings.
Any help on this would be really appreciated.
Many thanks.
You can try setting detailed_output property to false in the configuration file. This should stop these details from printing in the console.
You can find a sample config file here.
You can find relevant details available under Output Settings section of official docs here.
Update 1: This looks like a combo of properties which controls this and the below combo works for me.
live_output: false,
silent: true,
output: true,
detailed_output: false,
disable_error_log: false,

How to configure 'dictConfig' properly to use a different logging format?

I am trying to configure my logger using dictConfig to use a different format but it does not seem to be taking effect. Following is the code that I have (I am also simultaneously trying to suppress the logs from imported modules)-
import logging.config
import requests
logging.config.dictConfig({
'version': 1,
'disable_existing_loggers': True,
'formatters':{'standard': { 'format': "[%(asctime)s] [%(levelname)8s] - %(message)s", 'datefmt':"%d-%b-%Y %I:%M:%S %p"}},
'handlers': {'default': {'level': 'DEBUG', 'formatter': 'standard', 'class': 'logging.StreamHandler', 'stream': 'ext://sys.stdout'}},
'loggers':{'__main__': {'handlers': ['default'], 'level': 'DEBUG', 'propagate': False }}
})
req = requests.get('https://www.google.com')
logging.debug("Only thing that should be printed")
Output -
DEBUG:root:Only thing that should be printed
Expected Output -
[2020-04-04 22:46:24,866] [ DEBUG] - Only thing that should be printed
I learnt how to use dictConfig from this SO post.
If you look at the post post that you've mentioned, you will see that you forget a line :)
log = logging.getLogger(__name__)
log.debug("Only thing that should be printed")
The logger hierarchy must be defined explicitly in the logger name, using dot-notation.
When using the __name__ :
This means that logger names track the package/module hierarchy, and
it’s intuitively obvious where events are logged just from the logger
name.
For more explanations, the docs are pretty complete.

SimpleSAML configuration error, getting this error. What could be the issue?

When I load my SimpleSAML instance and try to authenticate using Google, I am getting following error:
"Debug information
The debug information below may be of interest to the administrator / help desk:
SimpleSAML_Error_Error: UNHANDLEDEXCEPTION
Backtrace:
0 /var/simplesamlphp/www/module.php:179 (N/A)
Caused by: Exception: Could not resolve 'authgoogle:Google': No class named 'sspmod_authgoogle_Auth_Source_Google'.
Backtrace:
6 /var/simplesamlphp/lib/SimpleSAML/Module.php:134 (SimpleSAML_Module::resolveClass)
5 /var/simplesamlphp/lib/SimpleSAML/Auth/Source.php:207 (SimpleSAML_Auth_Source::parseAuthSource)
4 /var/simplesamlphp/lib/SimpleSAML/Auth/Source.php:247 (SimpleSAML_Auth_Source::getById)
3 /var/simplesamlphp/lib/SimpleSAML/Auth/Default.php:59 (SimpleSAML_Auth_Default::initLogin)
2 /var/simplesamlphp/lib/SimpleSAML/Auth/Simple.php:136 (SimpleSAML_Auth_Simple::login)
1 /var/simplesamlphp/modules/core/www/authenticate.php:45 (require)
0 /var/simplesamlphp/www/module.php:134 (N/A)"
Any idea what is going on?
You need to enable SSP modules before you can use them.
touch [INSTALL_DIR]/modules/authgoogle/enable
If you create an enable file in the module directory then SSP's custom autoloader will load classes from that module.
I found the solution, on the config file is a part where its overriding the enable and disable file, just add the authgoogle module and it will work
/***********
| MODULES |
***********/
/*
* Configuration to override module enabling/disabling.
*
* Example:
*
* 'module.enable' => [
* 'exampleauth' => true, // Setting to TRUE enables.
* 'consent' => false, // Setting to FALSE disables.
* 'core' => null, // Unset or NULL uses default.
* ],
*
*/
'module.enable' => [
'exampleauth' => true,
'core' => true,
'saml' => true,
'authgoogle' => true
],

Resources