<commit_before>/*
 * Copyright (C) 2017 Black Duck Software, Inc.
 * http://www.blackducksoftware.com/
 *
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package com.blackducksoftware.integration.hub.detect

import org.springframework.beans.factory.annotation.Value
import org.springframework.stereotype.Component

import com.blackducksoftware.integration.hub.detect.help.ValueDescription

import groovy.transform.TypeChecked

@Component
@TypeChecked
class DetectProperties {
    private static final String GROUP_HUB_CONFIGURATION = 'hub configuration'
    private static final String GROUP_LOGGING = 'logging'
    private static final String GROUP_CLEANUP = 'cleanup'
    private static final String GROUP_PATHS = 'paths'
    private static final String GROUP_BOMTOOL = 'bomtool'
    private static final String GROUP_CONDA = 'conda'
    private static final String GROUP_CPAN = 'cpan'
    private static final String GROUP_DOCKER = 'docker'
    private static final String GROUP_GO = 'go'
    private static final String GROUP_GRADLE = 'gradle'
    private static final String GROUP_MAVEN = 'maven'
    private static final String GROUP_NPM = 'npm'
    private static final String GROUP_NUGET = 'nuget'
    private static final String GROUP_PACKAGIST = 'packagist'
    private static final String GROUP_PEAR = 'pear'
    private static final String GROUP_PIP = 'pip'
    private static final String GROUP_POLICY_CHECK = 'policy check'
    private static final String GROUP_PROJECT_INFO = 'project info'
    private static final String GROUP_PYTHON = 'python'
    private static final String GROUP_SBT = 'sbt'
    private static final String GROUP_SIGNATURE_SCANNER = 'signature scanner'

    @ValueDescription(description="If true, the default behavior of printing your configuration properties at startup will be suppressed.", defaultValue="false", group=DetectProperties.GROUP_LOGGING)
    @Value('${detect.suppress.configuration.output}')
    Boolean suppressConfigurationOutput

    @ValueDescription(description="If true the bdio files will be deleted after upload", defaultValue="true", group=DetectProperties.GROUP_CLEANUP)
    @Value('${detect.cleanup.bdio.files}')
    Boolean cleanupBdioFiles

    @ValueDescription(description="Test the connection to the Hub with the current configuration", defaultValue="false", group=DetectProperties.GROUP_HUB_CONFIGURATION)
    @Value('${detect.test.connection}')
    Boolean testConnection

    @ValueDescription(description="URL of the Hub server", group=DetectProperties.GROUP_HUB_CONFIGURATION)
    @Value('${blackduck.hub.url}')
    String hubUrl

    @ValueDescription(description="Time to wait for rest connections to complete", defaultValue="120", group=DetectProperties.GROUP_HUB_CONFIGURATION)
    @Value('${blackduck.hub.timeout}')
    Integer hubTimeout

    @ValueDescription(description="Hub username", group=DetectProperties.GROUP_HUB_CONFIGURATION)
    @Value('${blackduck.hub.username}')
    String hubUsername

    @ValueDescription(description="Hub password", group=DetectProperties.GROUP_HUB_CONFIGURATION)
    @Value('${blackduck.hub.password}')
    String hubPassword

    @ValueDescription(description="Proxy host", group=DetectProperties.GROUP_HUB_CONFIGURATION)
    @Value('${blackduck.hub.proxy.host}')
    String hubProxyHost

    @ValueDescription(description="Proxy port", group=DetectProperties.GROUP_HUB_CONFIGURATION)
    @Value('${blackduck.hub.proxy.port}')
    String hubProxyPort

    @ValueDescription(description="Proxy username", group=DetectProperties.GROUP_HUB_CONFIGURATION)
    @Value('${blackduck.hub.proxy.username}')
    String hubProxyUsername

    @ValueDescription(description="Proxy password", group=DetectProperties.GROUP_HUB_CONFIGURATION)
    @Value('${blackduck.hub.proxy.password}')
    String hubProxyPassword

    @ValueDescription(description="If true the Hub https certificate will be automatically imported", defaultValue="false", group=DetectProperties.GROUP_HUB_CONFIGURATION)
    @Value('${blackduck.hub.auto.import.cert}')
    Boolean hubAutoImportCertificate

    @ValueDescription(description="This can disable any Hub communication - if true, Detect will not upload BDIO files, it will not check policies, and it will not download and install the signature scanner.", defaultValue="false", group=DetectProperties.GROUP_HUB_CONFIGURATION)
    @Value('${blackduck.hub.offline.mode}')
    Boolean hubOfflineMode

    @ValueDescription(description = "Source path to inspect", group=DetectProperties.GROUP_PATHS)
    @Value('${detect.source.path}')
    String sourcePath

    @ValueDescription(description = "Output path", group=DetectProperties.GROUP_PATHS)
    @Value('${detect.output.path}')
    String outputDirectoryPath

    @ValueDescription(description = "Depth from source paths to search for files.", defaultValue="3", group=DetectProperties.GROUP_PATHS)
    @Value('${detect.search.depth}')
    Integer searchDepth

    @ValueDescription(description = "By default, all tools will be included. If you want to exclude specific tools, specify the ones to exclude here. Exclusion rules always win.", group=DetectProperties.GROUP_BOMTOOL)
    @Value('${detect.excluded.bom.tool.types}')
    String excludedBomToolTypes

    @ValueDescription(description = "By default, all tools will be included. If you want to include only specific tools, specify the ones to include here. Exclusion rules always win.", group=DetectProperties.GROUP_BOMTOOL)
    @Value('${detect.included.bom.tool.types}')
    String includedBomToolTypes

    @ValueDescription(description = "An override for the name to use for the Hub project. If not supplied, detect will attempt to use the tools to figure out a reasonable project name. If that fails, the final part of the directory path where the inspection is taking place will be used.", group=DetectProperties.GROUP_PROJECT_INFO)
    @Value('${detect.project.name}')
    String projectName

    @ValueDescription(description = "An override for the version to use for the Hub project. If not supplied, detect will attempt to use the tools to figure out a reasonable version name. If that fails, the current date will be used.", group=DetectProperties.GROUP_PROJECT_INFO)
    @Value('${detect.project.version.name}')
    String projectVersionName

    @ValueDescription(description = "A prefix to the name of the codelocations created by Detect. Useful for running against the same projects on multiple machines.", defaultValue='', group=DetectProperties.GROUP_PROJECT_INFO)
    @Value('${detect.project.codelocation.prefix}')
    String projectCodeLocationPrefix

    @ValueDescription(description = "An override for the Project level matches.", defaultValue="true", group=DetectProperties.GROUP_PROJECT_INFO)
    @Value('${detect.project.level.adjustments}')
    String projectLevelMatchAdjustments

    @ValueDescription(description = "An override for the Project Version phase.", defaultValue="Development",  group=DetectProperties.GROUP_PROJECT_INFO)
    @Value('${detect.project.version.phase}')
    String projectVersionPhase

    @ValueDescription(description = "An override for the Project Version distribution", defaultValue="External",  group=DetectProperties.GROUP_PROJECT_INFO)
    @Value('${detect.project.version.distribution}')
    String projectVersionDistribution

    @ValueDescription(description = "Set to true if you would like a policy check from the hub for your project. False by default", defaultValue="false", group=DetectProperties.GROUP_POLICY_CHECK)
    @Value('${detect.policy.check}')
    Boolean policyCheck

    @ValueDescription(description="Timeout for the Hub's policy check response. When changing this value, keep in mind the checking of policies might have to wait for a new scan to process which can take some time.", defaultValue="300000", group=DetectProperties.GROUP_POLICY_CHECK)
    @Value('${detect.policy.check.timeout}')
    Long policyCheckTimeout

    @ValueDescription(description="Version of the Gradle Inspector", defaultValue="0.2.2", group=DetectProperties.GROUP_GRADLE)
    @Value('${detect.gradle.inspector.version}')
    String gradleInspectorVersion

    @ValueDescription(description="Gradle build command", defaultValue="dependencies", group=DetectProperties.GROUP_GRADLE)
    @Value('${detect.gradle.build.command}')
    String gradleBuildCommand

    @ValueDescription(description="The names of the dependency configurations to exclude", group=DetectProperties.GROUP_GRADLE)
    @Value('${detect.gradle.excluded.configurations}')
    String gradleExcludedConfigurationNames

    @ValueDescription( description="The names of the dependency configurations to include", group=DetectProperties.GROUP_GRADLE)
    @Value('${detect.gradle.included.configurations}')
    String gradleIncludedConfigurationNames

    @ValueDescription(description="The names of the projects to exclude", group=DetectProperties.GROUP_GRADLE)
    @Value('${detect.gradle.excluded.projects}')
    String gradleExcludedProjectNames

    @ValueDescription(description="The names of the projects to include", group=DetectProperties.GROUP_GRADLE)
    @Value('${detect.gradle.included.projects}')
    String gradleIncludedProjectNames

    @ValueDescription(description="Set this to false if you do not want the 'blackduck' directory in your build directory to be deleted.", defaultValue="true", group=DetectProperties.GROUP_GRADLE)
    @Value('${detect.gradle.cleanup.build.blackduck.directory}')
    Boolean gradleCleanupBuildBlackduckDirectory

    @ValueDescription(description="Name of the Nuget Inspector", defaultValue="IntegrationNugetInspector", group=DetectProperties.GROUP_NUGET)
    @Value('${detect.nuget.inspector.name}')
    String nugetInspectorPackageName

    @ValueDescription(description="Version of the Nuget Inspector", defaultValue="2.1.1", group=DetectProperties.GROUP_NUGET)
    @Value('${detect.nuget.inspector.version}')
    String nugetInspectorPackageVersion

    @ValueDescription(description="The names of the projects in a solution to exclude", group=DetectProperties.GROUP_NUGET)
    @Value('${detect.nuget.excluded.modules}')
    String nugetInspectorExcludedModules

    @ValueDescription(description="If true errors will be logged and then ignored.", defaultValue="false", group=DetectProperties.GROUP_NUGET)
    @Value('${detect.nuget.ignore.failure}')
    Boolean nugetInspectorIgnoreFailure

    @ValueDescription(description="The name of the dependency scope to include", group=DetectProperties.GROUP_MAVEN)
    @Value('${detect.maven.scope}')
    String mavenScope

    @ValueDescription(description="Path of the Gradle executable", group=DetectProperties.GROUP_GRADLE)
    @Value('${detect.gradle.path}')
    String gradlePath

    @ValueDescription(description="The path of the Maven executable", group=DetectProperties.GROUP_MAVEN)
    @Value('${detect.maven.path}')
    String mavenPath

    @ValueDescription(description="The path of the Nuget executable", group=DetectProperties.GROUP_NUGET)
    @Value('${detect.nuget.path}')<commit_msg>Updating Nuget inspector version to 2.1.2<commit_after>/*
 * Copyright (C) 2017 Black Duck Software, Inc.
 * http://www.blackducksoftware.com/
 *
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package com.blackducksoftware.integration.hub.detect

import org.springframework.beans.factory.annotation.Value
import org.springframework.stereotype.Component

import com.blackducksoftware.integration.hub.detect.help.ValueDescription

import groovy.transform.TypeChecked

@Component
@TypeChecked
class DetectProperties {
    private static final String GROUP_HUB_CONFIGURATION = 'hub configuration'
    private static final String GROUP_LOGGING = 'logging'
    private static final String GROUP_CLEANUP = 'cleanup'
    private static final String GROUP_PATHS = 'paths'
    private static final String GROUP_BOMTOOL = 'bomtool'
    private static final String GROUP_CONDA = 'conda'
    private static final String GROUP_CPAN = 'cpan'
    private static final String GROUP_DOCKER = 'docker'
    private static final String GROUP_GO = 'go'
    private static final String GROUP_GRADLE = 'gradle'
    private static final String GROUP_MAVEN = 'maven'
    private static final String GROUP_NPM = 'npm'
    private static final String GROUP_NUGET = 'nuget'
    private static final String GROUP_PACKAGIST = 'packagist'
    private static final String GROUP_PEAR = 'pear'
    private static final String GROUP_PIP = 'pip'
    private static final String GROUP_POLICY_CHECK = 'policy check'
    private static final String GROUP_PROJECT_INFO = 'project info'
    private static final String GROUP_PYTHON = 'python'
    private static final String GROUP_SBT = 'sbt'
    private static final String GROUP_SIGNATURE_SCANNER = 'signature scanner'

    @ValueDescription(description="If true, the default behavior of printing your configuration properties at startup will be suppressed.", defaultValue="false", group=DetectProperties.GROUP_LOGGING)
    @Value('${detect.suppress.configuration.output}')
    Boolean suppressConfigurationOutput

    @ValueDescription(description="If true the bdio files will be deleted after upload", defaultValue="true", group=DetectProperties.GROUP_CLEANUP)
    @Value('${detect.cleanup.bdio.files}')
    Boolean cleanupBdioFiles

    @ValueDescription(description="Test the connection to the Hub with the current configuration", defaultValue="false", group=DetectProperties.GROUP_HUB_CONFIGURATION)
    @Value('${detect.test.connection}')
    Boolean testConnection

    @ValueDescription(description="URL of the Hub server", group=DetectProperties.GROUP_HUB_CONFIGURATION)
    @Value('${blackduck.hub.url}')
    String hubUrl

    @ValueDescription(description="Time to wait for rest connections to complete", defaultValue="120", group=DetectProperties.GROUP_HUB_CONFIGURATION)
    @Value('${blackduck.hub.timeout}')
    Integer hubTimeout

    @ValueDescription(description="Hub username", group=DetectProperties.GROUP_HUB_CONFIGURATION)
    @Value('${blackduck.hub.username}')
    String hubUsername

    @ValueDescription(description="Hub password", group=DetectProperties.GROUP_HUB_CONFIGURATION)
    @Value('${blackduck.hub.password}')
    String hubPassword

    @ValueDescription(description="Proxy host", group=DetectProperties.GROUP_HUB_CONFIGURATION)
    @Value('${blackduck.hub.proxy.host}')
    String hubProxyHost

    @ValueDescription(description="Proxy port", group=DetectProperties.GROUP_HUB_CONFIGURATION)
    @Value('${blackduck.hub.proxy.port}')
    String hubProxyPort

    @ValueDescription(description="Proxy username", group=DetectProperties.GROUP_HUB_CONFIGURATION)
    @Value('${blackduck.hub.proxy.username}')
    String hubProxyUsername

    @ValueDescription(description="Proxy password", group=DetectProperties.GROUP_HUB_CONFIGURATION)
    @Value('${blackduck.hub.proxy.password}')
    String hubProxyPassword

    @ValueDescription(description="If true the Hub https certificate will be automatically imported", defaultValue="false", group=DetectProperties.GROUP_HUB_CONFIGURATION)
    @Value('${blackduck.hub.auto.import.cert}')
    Boolean hubAutoImportCertificate

    @ValueDescription(description="This can disable any Hub communication - if true, Detect will not upload BDIO files, it will not check policies, and it will not download and install the signature scanner.", defaultValue="false", group=DetectProperties.GROUP_HUB_CONFIGURATION)
    @Value('${blackduck.hub.offline.mode}')
    Boolean hubOfflineMode

    @ValueDescription(description = "Source path to inspect", group=DetectProperties.GROUP_PATHS)
    @Value('${detect.source.path}')
    String sourcePath

    @ValueDescription(description = "Output path", group=DetectProperties.GROUP_PATHS)
    @Value('${detect.output.path}')
    String outputDirectoryPath

    @ValueDescription(description = "Depth from source paths to search for files.", defaultValue="3", group=DetectProperties.GROUP_PATHS)
    @Value('${detect.search.depth}')
    Integer searchDepth

    @ValueDescription(description = "By default, all tools will be included. If you want to exclude specific tools, specify the ones to exclude here. Exclusion rules always win.", group=DetectProperties.GROUP_BOMTOOL)
    @Value('${detect.excluded.bom.tool.types}')
    String excludedBomToolTypes

    @ValueDescription(description = "By default, all tools will be included. If you want to include only specific tools, specify the ones to include here. Exclusion rules always win.", group=DetectProperties.GROUP_BOMTOOL)
    @Value('${detect.included.bom.tool.types}')
    String includedBomToolTypes

    @ValueDescription(description = "An override for the name to use for the Hub project. If not supplied, detect will attempt to use the tools to figure out a reasonable project name. If that fails, the final part of the directory path where the inspection is taking place will be used.", group=DetectProperties.GROUP_PROJECT_INFO)
    @Value('${detect.project.name}')
    String projectName

    @ValueDescription(description = "An override for the version to use for the Hub project. If not supplied, detect will attempt to use the tools to figure out a reasonable version name. If that fails, the current date will be used.", group=DetectProperties.GROUP_PROJECT_INFO)
    @Value('${detect.project.version.name}')
    String projectVersionName

    @ValueDescription(description = "A prefix to the name of the codelocations created by Detect. Useful for running against the same projects on multiple machines.", defaultValue='', group=DetectProperties.GROUP_PROJECT_INFO)
    @Value('${detect.project.codelocation.prefix}')
    String projectCodeLocationPrefix

    @ValueDescription(description = "An override for the Project level matches.", defaultValue="true", group=DetectProperties.GROUP_PROJECT_INFO)
    @Value('${detect.project.level.adjustments}')
    String projectLevelMatchAdjustments

    @ValueDescription(description = "An override for the Project Version phase.", defaultValue="Development",  group=DetectProperties.GROUP_PROJECT_INFO)
    @Value('${detect.project.version.phase}')
    String projectVersionPhase

    @ValueDescription(description = "An override for the Project Version distribution", defaultValue="External",  group=DetectProperties.GROUP_PROJECT_INFO)
    @Value('${detect.project.version.distribution}')
    String projectVersionDistribution

    @ValueDescription(description = "Set to true if you would like a policy check from the hub for your project. False by default", defaultValue="false", group=DetectProperties.GROUP_POLICY_CHECK)
    @Value('${detect.policy.check}')
    Boolean policyCheck

    @ValueDescription(description="Timeout for the Hub's policy check response. When changing this value, keep in mind the checking of policies might have to wait for a new scan to process which can take some time.", defaultValue="300000", group=DetectProperties.GROUP_POLICY_CHECK)
    @Value('${detect.policy.check.timeout}')
    Long policyCheckTimeout

    @ValueDescription(description="Version of the Gradle Inspector", defaultValue="0.2.2", group=DetectProperties.GROUP_GRADLE)
    @Value('${detect.gradle.inspector.version}')
    String gradleInspectorVersion

    @ValueDescription(description="Gradle build command", defaultValue="dependencies", group=DetectProperties.GROUP_GRADLE)
    @Value('${detect.gradle.build.command}')
    String gradleBuildCommand

    @ValueDescription(description="The names of the dependency configurations to exclude", group=DetectProperties.GROUP_GRADLE)
    @Value('${detect.gradle.excluded.configurations}')
    String gradleExcludedConfigurationNames

    @ValueDescription( description="The names of the dependency configurations to include", group=DetectProperties.GROUP_GRADLE)
    @Value('${detect.gradle.included.configurations}')
    String gradleIncludedConfigurationNames

    @ValueDescription(description="The names of the projects to exclude", group=DetectProperties.GROUP_GRADLE)
    @Value('${detect.gradle.excluded.projects}')
    String gradleExcludedProjectNames

    @ValueDescription(description="The names of the projects to include", group=DetectProperties.GROUP_GRADLE)
    @Value('${detect.gradle.included.projects}')
    String gradleIncludedProjectNames

    @ValueDescription(description="Set this to false if you do not want the 'blackduck' directory in your build directory to be deleted.", defaultValue="true", group=DetectProperties.GROUP_GRADLE)
    @Value('${detect.gradle.cleanup.build.blackduck.directory}')
    Boolean gradleCleanupBuildBlackduckDirectory

    @ValueDescription(description="Name of the Nuget Inspector", defaultValue="IntegrationNugetInspector", group=DetectProperties.GROUP_NUGET)
    @Value('${detect.nuget.inspector.name}')
    String nugetInspectorPackageName

    @ValueDescription(description="Version of the Nuget Inspector", defaultValue="2.1.2", group=DetectProperties.GROUP_NUGET)
    @Value('${detect.nuget.inspector.version}')
    String nugetInspectorPackageVersion

    @ValueDescription(description="The names of the projects in a solution to exclude", group=DetectProperties.GROUP_NUGET)
    @Value('${detect.nuget.excluded.modules}')
    String nugetInspectorExcludedModules

    @ValueDescription(description="If true errors will be logged and then ignored.", defaultValue="false", group=DetectProperties.GROUP_NUGET)
    @Value('${detect.nuget.ignore.failure}')
    Boolean nugetInspectorIgnoreFailure

    @ValueDescription(description="The name of the dependency scope to include", group=DetectProperties.GROUP_MAVEN)
    @Value('${detect.maven.scope}')
    String mavenScope

    @ValueDescription(description="Path of the Gradle executable", group=DetectProperties.GROUP_GRADLE)
    @Value('${detect.gradle.path}')
    String gradlePath

    @ValueDescription(description="The path of the Maven executable", group=DetectProperties.GROUP_MAVEN)
    @Value('${detect.maven.path}')
    String mavenPath

    @ValueDescription(description="The path of the Nuget executable", group=DetectProperties.GROUP_NUGET)
    @Value('${detect.nuget.path}')
{'fraction_non_alphanumeric': 0.09164693946567468, 'fraction_numerical': 0.0021559012512681773, 'mean_word_length': 5.446049046321526, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4336606', 'n_tokens_mistral': 6416, 'n_tokens_neox': 6045, 'n_words': 1824}