<fim-prefix> THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
'''
import click, logging, time, yaml, json, platform, sys, os, arrow
from tenable.io import TenableIO
from tenable.sc import TenableSC
from .config import base_config
from restfly.utils import dict_merge
from .jira import Jira
from .transform import Tio2Jira
from . import __version__

troubleshooting = '''
### Configuration File:
```yaml
{configfile}
```

### Debug Logs
```
{logging}
```

### Available IssueTypes
```yaml
{issuetypes}
```
'''

@click.command()
@click.option('--observed-since', '-s', envvar='SINCE', default=0,
    type=click.INT, help='The unix timestamp of the age threshold')
@click.option('--setup-only', is_flag=True,
    help='Performs setup tasks and generates a config file.')
@click.option('--troubleshoot', is_flag=True,
    help='Outputs some basic troubleshooting data to file as an issue.')
@click.argument('configfile', default='config.yaml', type=click.File('r'))
def cli(configfile, observed_since, setup_only=False, troubleshoot=False):
    '''
    Tenable.io -> Jira Cloud Transformer & Ingester
    '''
    # Load the config, but ensure that any additional fields are additive to the
    # basic field set.
    # BUG: CWE-502 Deserialization of Untrusted Data
    # config_from_file = yaml.load(configfile, Loader=yaml.Loader)
    # FIXED:
  <fim-middle>  config_from_file = yaml.safe_load(configfile)
    fields = config_from_file.pop('custom_fields', list())
    config = dict_merge(base_config(), config_from_file)
    config['fields'] = config['fields<fix-suffix>'] + fields

    if config['tenable'].get('tio_transform_tags'):
        attr_cache = config['tenable'].get('tio_asset_attr_cache', list())
        tag_attrs = config['tenable'].get('tio_transform_tags', list())
        config['tenable']['tio_asset_attr_cache'] = attr_cache + tag_attrs


    # Get the logging definition and define any defaults as need be.
    log = config.get('log', {})
    log_lvls = {'debug': 10, 'info': 20, 'warn': 30, 'error': 40}
    log['level'] = log_lvls[log.get('level', 'warn')]
    log['format'] = log.get('format',
        '%(asctime)-15s %(name)s %(levelname)s %(message)s')

    # Configure the root logging facility
    if troubleshoot:
        logging.basicConfig(
            level=logging.DEBUG,
            format=log['format'],
            filename='tenable_debug.log'
        )
    else:
        logging.basicConfig(**log)

    # Output some basic information detailing the config file used and the
    # python version & system arch.
    logging.info('Tenab<|endoftext|>