{"id":37023167,"url":"https://github.com/civitz/viper","last_synced_at":"2026-01-14T02:46:38.102Z","repository":{"id":43607650,"uuid":"70189011","full_name":"civitz/viper","owner":"civitz","description":"A generator and a framework for injecting configurations via CDI","archived":false,"fork":false,"pushed_at":"2023-06-14T22:28:53.000Z","size":133,"stargazers_count":10,"open_issues_count":3,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-07-09T08:27:09.531Z","etag":null,"topics":["cdi","configuration","injection","java","javaee"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/civitz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-06T20:08:34.000Z","updated_at":"2024-08-08T11:50:38.000Z","dependencies_parsed_at":"2022-09-10T17:50:56.579Z","dependency_job_id":null,"html_url":"https://github.com/civitz/viper","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/civitz/viper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/civitz%2Fviper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/civitz%2Fviper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/civitz%2Fviper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/civitz%2Fviper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/civitz","download_url":"https://codeload.github.com/civitz/viper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/civitz%2Fviper/sbom","scorecard":{"id":283966,"data":{"date":"2025-08-11","repo":{"name":"github.com/civitz/viper","commit":"082514abbf856c251b1550feed344a672631e582"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":2,"reason":"Found 3/15 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 22 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T16:44:43.533Z","repository_id":43607650,"created_at":"2025-08-17T16:44:43.533Z","updated_at":"2025-08-17T16:44:43.533Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408737,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cdi","configuration","injection","java","javaee"],"created_at":"2026-01-14T02:46:37.429Z","updated_at":"2026-01-14T02:46:38.092Z","avatar_url":"https://github.com/civitz.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Viper\n\n[![Join the chat at https://gitter.im/cdi-viper/Lobby](https://badges.gitter.im/cdi-viper/Lobby.svg)](https://gitter.im/cdi-viper/Lobby?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n![Build status](https://api.travis-ci.org/civitz/viper.svg)\n\nA generator and a framework for injecting configurations via the java EE's CDI.\n\nPut all your configuration keys in an enum, and make viper inject the configurations in your beans.\n\n## Why another configuration library?\n\nThere are many configuration frameworks around, and everyone is good in its own way. For those which support CDI-based configuration injection, the magic is usually done via annotation from the framework.\n\nWhat happens with framework-provided annotations is:\n- you can not trace back which configuration you need until you actually create an instance of an object and thus trigger configuration injection\n- each object is aware of the configuration keys it actually needs from the configuration source (e.g. the key in a configuration file)\n- injection happens necessarily with String-based keys\n\nWhat we want is a single source to enumerate the available configuration keys an application may need. By doing this we can:\n\n- centralize the source and know in advance which configurations an application will need\n- place validation criterias alongside configuration keys\n- make sure the inject-able configurations come only from the pool of known configurations\n\nWe found a way to do this by using enums to limit the configuration keys, and generating the necessary annotations and configuration-injection code.\n\nWant to try this?\n\n## As simple as\n\nImport library and generators in maven:\n\n```xml\n\u003cdependency\u003e\n\t\u003cgroupId\u003ecom.github.civitz.viper\u003c/groupId\u003e\n\t\u003cartifactId\u003elibrary\u003c/artifactId\u003e\n\t\u003cversion\u003e0.2.0\u003c/version\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e\n\t\u003cgroupId\u003ecom.github.civitz.viper\u003c/groupId\u003e\n\t\u003cartifactId\u003egenerator\u003c/artifactId\u003e\n\t\u003cversion\u003e0.2.0\u003c/version\u003e\n\t\u003cscope\u003eprovided\u003c/scope\u003e\n\t\u003coptional\u003etrue\u003c/optional\u003e\n\u003c/dependency\u003e\n\n```\n\nYou can also skip the generator dependency if you use `maven-compiler-plugin` version 3.5+ by using this plugin configuration:\n```xml\n\u003cplugin\u003e\n\t\u003cgroupId\u003eorg.apache.maven.plugins\u003c/groupId\u003e\n\t\u003cartifactId\u003emaven-compiler-plugin\u003c/artifactId\u003e\n\t\u003cconfiguration\u003e\n\t\t\u003cuseIncrementalCompilation\u003efalse\u003c/useIncrementalCompilation\u003e\n\t\t\u003cannotationProcessorPaths\u003e\n\t\t\t\u003cannotationProcessorPath\u003e\n\t\t\t\t\u003cgroupId\u003ecom.github.civitz.viper\u003c/groupId\u003e\n\t\t\t\t\u003cartifactId\u003egenerator\u003c/artifactId\u003e\n\t\t\t\t\u003cversion\u003e0.2.0\u003c/version\u003e\n\t\t\t\u003c/annotationProcessorPath\u003e\n\t\t\u003c/annotationProcessorPaths\u003e\n\t\u003c/configuration\u003e\n\u003c/plugin\u003e\n```\n\nBe also sure to have the [Contexts and Dependency Injection for Java EE (CDI)](http://cdi-spec.org/) API as a dependency.\n\nThen annotate the enum of your configuration keys as follows:\n\n```java\n\npackage tests;\n\nimport civitz.viper.CdiConfiguration;\n\n@CdiConfiguration\n@PropertyFileResolver(propertiesPath = \"/tmp/viper/my.config\")\npublic enum MyConfigs {\t\n\tFIRST_PROPERTY,\n\tSECOND_PROPERTY;\n}\n```\n\nViper will generate a `MyConfigsPropertyFileConfigurationResolver` class, which will read properties from the specified path: by default it will assume your properties are `Properties`-compatible, and use `key.name().toLowerCase()` as key.\nYou can also override the path via system property. The default is `{Enum name}ConfigPath`, or `MyConfigsConfigPath` here.\n\nIt will create a `MyConfigsConfiguration` qualifier annotation, in this form:\n```java\n@Qualifier\n@Retention(RetentionPolicy.RUNTIME)\n@Target({FIELD,TYPE,METHOD,PARAMETER})\npublic @interface MyConfigsConfiguration {\n\t@Nonbinding\n\tMyConfigs value() default MyConfigs.FIRST_PROPERTY;\n}\n\n```\nIt will also generate a `MyConfigsConfigurationBean` class, which will inject your `MyConfigsConfiguration` annotated configuration.\n\nYou can use the generated code in this way:\n\n```java\n\npackage tests.logic;\n\nimport javax.inject.Inject;\nimport tests.MyConfigsConfiguration; // this is generated\nimport tests.MyConfigs;\n\npublic MyApplicationLogic {\n\n\t@Inject \n\t@MyConfigsConfiguration(MyConfigs.FIRST_PROPERTY)\n\tString firstProperty;\n\t\n\t@Inject\n\t@MyConfigsConfiguration(MyConfigs.SECOND_PROPERTY)\n\tString secondProperty;\n\n\tvoid myMethod() {\n\t\t// use the property, Luke\n\t}\n}\n```\n\n## A more complex example\n\nYou can tune the generated bean with more annotations:\n\n```java\npackage tests;\nimport java.util.function.Predicate;\n\nimport javax.enterprise.context.ApplicationScoped;\n\nimport com.google.common.primitives.Ints;\n\nimport viper.CdiConfiguration;\nimport viper.PropertyFileResolver;\n\n/*\n * You can specify one or more annotations for the Configuration Bean.\n * In this case, Configuration Bean will have the ApplicationScoped qualifier\n */\n@CdiConfiguration.PassAnnotations(ApplicationScoped.class)\n/*\n * Tell the processor to create producers also for primitive types: Byte,\n * Character, Short, Integer, Long, Float, Double, Boolean. Take this feature\n * with care: we don't verify if the transformation from string is possible,\n * exceptions may be thrown.\n * \n * You can also specify the name of the generated annotation and configuration\n * bean. You can put a star symbol in it, and the processor will replace it with\n * the enum name.\n */\n@CdiConfiguration(producersForPrimitives = true, annotationName = \"MyConfig\", configurationBeanName = \"*ConfInjector\")\n/*\n * Generate a Properties-based file-sourced configuration resolver with the\n * given configuration file's path. You can override the path via a\n * custom system property. The default is \u003ccode\u003e{Enum name}ConfigPath\u003c/code\u003e\n * but here we use a custom variable named \u003ccode\u003emy_config_path\u003c/code\u003e.\n */\n@PropertyFileResolver(propertiesPath = \"/tmp/viper/my.config\", systemPropertyName=\"my_config_path\")\npublic enum CompleteEnum {\n\n\tFIRST_PROPERTY(\"my.particular.key\", s -\u003e Ints.tryParse(s) != null),\n\n\t/*\n\t * You can mark a specific enum constant to be the default key instead of the\n\t * first one\n\t */\n\t@CdiConfiguration.DefaultKey\n\tSECOND_PROPERTY(\"my.other.key\", s -\u003e s.length() \u003e= 10);\n\t\n\n\tString key;\n\tPredicate\u003cString\u003e validator;\n\n\tCompleteEnum(String key) {\n\t\tthis(key, s -\u003e true);\n\t}\n\n\tCompleteEnum(String key, Predicate\u003cString\u003e validator) {\n\t\tthis.key = key;\n\t\tthis.validator = validator;\n\t}\n\n\t/*\n\t * You can specify a method to get a validator for a property: if the\n\t * property is not valid, the Configuration Bean will throw an\n\t * IllegalArgumentException in the initialization method.\n\t */\n\t@CdiConfiguration.ConfigValidator\n\tpublic Predicate\u003cString\u003e getValidator() {\n\t\treturn validator;\n\t}\n\n\t/*\n\t * You can specify a method to get a particular string value as a property\n\t * key instead of the generic enum constant name in lowercase.\n\t */\n\t@PropertyFileResolver.KeyString\n\tpublic String getKeyString() {\n\t\treturn key;\n\t}\n}\n\n```\n\n## A custom configuration resolver\n\nYou can omit the `@PropertyFileResolver` and provide your own @Inject-able implementation of `ConfigurationResolver\u003cYourEnum\u003e` via CDI. For example, supposing you have this enum:\n\n```java\npackage tests;\n\nimport civitz.viper.CdiConfiguration;\n\n@CdiConfiguration\npublic enum MyConfigs {\t\n\tFIRST_PROPERTY,\n\tSECOND_PROPERTY;\n}\n```\n\nYou can write your own:\n\n```java\npackage test;\n\nimport viper.ConfigurationResolver;\n\npublic class OuterSpaceConfigurationResolver implements ConfigurationResolver\u003cMyConfigs\u003e {\n\n\t@Override\n\tpublic String getConfigurationValue(MyConfigs key) {\n\t\t// you can extract data from the enum here, since you know it\n\t\treturn fetchConfigurationValueFromOuterSpace(key);\n\t}\n\t\n\t/*\n\t * You can optionally override getConfigurationKey to provide a meaningful\n\t * string representation of your configuration key.\n\t */\n\t@Override\n\tpublic String getConfigurationKey(MyConfigs key) {\n\t\treturn \"my.conf.prefix.\"+key.name().toLowerCase();\n\t}\n\n\t// implementation for fetchConfigurationValueFromOuterSpace omitted\n}\n```\n\nAnd the generated `MyConfigsConfigurationBean` will use that class (via CDI, so be sure it's inject-able) to resolve properties.\n\nBe aware of the fact that you can't inject `MyConfigs` properties in your own resolver, since it would create a circular injection dependency. Use another method to configure your resolver (e.g. read properties from file, or from `System`).\n\n## Suggested use\n\nWe suggest to:\n\n- provide a validator and at least check for null values if you do not want them (by default we do not check)\n- if you build a custom resolver please implement the `getConfigurationKey` method and provide a textual description for when configuration values are invalid\n- pass at least `javax.enterprise.context.ApplicationScoped` annotation to the `ConfigurationBean` to avoid multiple validation of properties.\n\n## Contribute\n\nIf you find a bug or want to discuss new features, please file an issue first ;)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcivitz%2Fviper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcivitz%2Fviper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcivitz%2Fviper/lists"}