From 460149fd5fe46f1968603ccfdbba2a9b55e6454e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20SZKIBA?= Date: Mon, 16 Nov 2026 19:22:24 +0100 Subject: [PATCH] docs: modernize README and add community files Rewrite the README for the current state of the project and add CONTRIBUTING, CODE_OF_CONDUCT, SECURITY and CHANGELOG, so the repository has the standard files for the 0.6.0 release. Update the copyright years in NOTICE.txt. --- CHANGELOG.md | 143 +++++++++++++++++++++++++++++++++++++++++++++ CODE_OF_CONDUCT.md | 86 +++++++++++++++++++++++++++ CONTRIBUTING.md | 68 +++++++++++++++++++++ NOTICE.txt | 2 +- README.md | 133 +++++++++++++++++++++++++++++++---------- SECURITY.md | 26 +++++++++ 6 files changed, 427 insertions(+), 31 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 SECURITY.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..283dd1a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,143 @@ +# Changelog + +All notable changes to this project are listed here. The format follows +[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses +[Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +Releases before 0.5.0 are described in +[src/changes/changes.xml](src/changes/changes.xml). Numbers like "SourceForge +#3038645" are ids from the old SourceForge tracker. + +The 0.5.2 date is the date of its tag and its Maven Central upload; +`changes.xml` says 2011-12-13. + +## [Unreleased] + +### Security + +- Fixed CVE-2022-41404, a denial of service. Option values that refer to each + other, such as `[a] x=${b/y}` and `[b] y=${a/x}`, caused a + `StackOverflowError`. Resolving a variable now stops after 16 levels and + throws the new `CircularReferenceException`. The limit is the new + `maxResolveDepth` setting, which you can change with + `-Dorg.ini4j.config.maxResolveDepth=N` or + `Config.getGlobal().setMaxResolveDepth(int)`. Reported on SourceForge by + bingdian. + +### Changed + +- **Breaking:** ini4j now needs Java 17 or newer. +- **Breaking:** `Profile.remove(sectionName, optionName)` is now + `Profile.removeOption(sectionName, optionName)`, because the old name clashes + with `Map.remove` on Java 17. +- The project moved from SourceForge (SVN) to GitHub (Git), and the POM was + modernized. +- Source code is formatted with Google Java Style. +- The Javadoc build now fails on a broken reference or tag. + +### Fixed + +- Replaced APIs that are deprecated in Java 17: `Class.newInstance()` and the + `Character`, `Double` and `Float` constructors. +- Dynamic bean proxies no longer fail when the thread has no context class + loader. +- Fixed how `BasicProfile` handles a bean property prefix together with + `propertyFirstUpper`. +- Fixed the SCM URL in `pom.xml` so deploying to Maven Central works. The old + `changes.xml` lists this as version 0.5.5, but that version was never tagged + and is not on Maven Central. + +### Added + +- GitHub Actions workflow that runs the build, tests, Spotless, SpotBugs and + PMD on pushes to `main` and on pull requests against `main`, except for + changes that only touch `docs/`. +- Javadoc for the public API of `org.ini4j` and `org.ini4j.spi`. +- Dev container configuration. + +## [0.5.4] - 2015-02-16 + +### Fixed + +- Updated the release part of the build for the new Maven Central policy. + +## [0.5.3] - 2015-02-13 + +This version is tagged but was not published to Maven Central. + +### Added + +- New config option `escapeKeyOnly`. When `escape` is on, `escapeKeyOnly` + turns off escaping of values. + +### Fixed + +- Operators (`:` or `=`) in property and option names are now escaped by both + the parser and the formatter. + +## [0.5.2] - 2011-07-05 + +### Added + +- Default value support in `get` and `fetch`: pass the default as the last + argument and it is returned for a missing option (SourceForge #3047041). +- Configurable comment handling: `Config.setHeaderComment(boolean)` switches + the header comment on or off, and `Config.setComment(boolean)` does the same + for all comments (SourceForge #2971952). +- Byte order mark (BOM) support, as a workaround for the Java BOM and UTF-8 + problem (SourceForge #2866427). + +### Changed + +- The `UnicodeLittle` and `UnicodeBig` charset references were removed because + they broke the Java 1.4 backport (SourceForge #2778337). + +### Fixed + +- A backslash at the end of a line joined it with the next line even when + escaping was off. The new `escapeNewline` option turns line joining off. It + is on by default for `Wini` (SourceForge #3038645). +- Using more than one `${...}` macro in one option value did not work + (SourceForge #2817403). +- Fixes for the Java 1.4 backport. The tests now also run on a Java 1.4 JVM + (SourceForge #2908623). +- Typo in the Options tutorial (SourceForge #2817399). + +## [0.5.1] - 2009-04-08 + +### Added + +- Applet support, and a small demo applet on the project site. + +### Fixed + +- Removed a `java.util.NavigableMap` reference that broke Java 1.5 + compatibility. + +## [0.5.0] - 2009-04-02 + +### Added + +- `Reg` class that reads and writes the Windows registry and `.reg` files. It + has the same data model as `Ini`. +- Sections form a tree with subsections, based on the section name and a + separator (`/` or `\`), like in `.reg` files. +- Comment support in `Ini` and `Options`: a header comment, section comments and + option comments. +- Bean property mapping with an upper case first letter in key names, as in + Mozilla `.ini` files (SourceForge #2706511). +- More convenient access methods in `OptionBundle` and `OptionMap`. + +### Changed + +- `Ini` was refactored into the `Profile` interface and the `BasicProfile` + superclass. +- A backslash at the end of a line joins the line with the next one. +- Removed deprecated methods and classes. + +[Unreleased]: https://github.com/ini4j/ini4j/compare/ini4j-0.5.4...main +[0.5.4]: https://github.com/ini4j/ini4j/compare/ini4j-0.5.3...ini4j-0.5.4 +[0.5.3]: https://github.com/ini4j/ini4j/compare/ini4j-0.5.2...ini4j-0.5.3 +[0.5.2]: https://github.com/ini4j/ini4j/compare/ini4j-0.5.1...ini4j-0.5.2 +[0.5.1]: https://github.com/ini4j/ini4j/compare/ini4j-0.5.0...ini4j-0.5.1 +[0.5.0]: https://github.com/ini4j/ini4j/releases/tag/ini4j-0.5.0 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..56070bd --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,86 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement through GitHub's private reporting form at . The form is built for security reports, so use it for conduct reports too and start the title with "Code of conduct". The community leader responsible for enforcement is the maintainer, Ivan Szkiba. All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of actions. + +**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations][translations]. + +The Contributor Covenant is licensed under [CC BY 4.0][license]. This copy changes only how to report: the contact method in the Enforcement section is filled in for this project. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations +[license]: https://creativecommons.org/licenses/by/4.0/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..d2a0c5e --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,68 @@ +# Contributing to ini4j + +Bug reports, questions, ideas and pull requests are welcome. This project follows the [Code of Conduct](CODE_OF_CONDUCT.md). + +## Reporting bugs and asking questions + +Use [GitHub issues](https://github.com/ini4j/ini4j/issues). The old +SourceForge trackers are no longer used. For a bug, include the ini4j version, +your Java version, a minimal `.ini` file or code sample that shows the problem, +what you expected and what happened. + +If you found a security problem, do not open an issue. Follow +[SECURITY.md](SECURITY.md). + +## Setting up + +You need JDK 17 and Maven. The repository also has a dev container in +`.devcontainer` with both installed. + +```sh +git clone https://github.com/ini4j/ini4j.git +cd ini4j +mvn -B clean verify +``` + +`verify` compiles the code, runs the tests, builds the Javadoc and checks +formatting. To run one test class while you work: + +```sh +mvn -Dtest=IniTest test +``` + +CI runs `mvn -B clean verify -Pci`, which adds SpotBugs and PMD. Run that +before you open a pull request, because a failing check fails the build. + +## Code style + +Java code follows Google Java Style, and XML files (including `pom.xml`) are +formatted by Spotless. If the build reports a formatting problem, fix it with: + +```sh +mvn spotless:apply +``` + +Tests use JUnit 4 and live in `src/test/java`. Add a test for every bug fix and +every change in behavior. Keep public API changes small and call them out in +your pull request. + +## Pull requests + +Work from the `main` branch and open the pull request against `main`. Small, +focused pull requests are easier to review than large ones. + +Commit messages follow [Conventional Commits](https://www.conventionalcommits.org/), +for example `fix(java): handle empty option names` or `docs: fix typo in +README`. Common scopes are `java`, `docs`, `website` and `release`. Mark +breaking changes with `!` or a `BREAKING CHANGE:` footer. Describe why the +change is needed in the commit message and the pull request, not only what it +does. + +Add a line to the `Unreleased` section of [CHANGELOG.md](CHANGELOG.md) when +your change is visible to users. + +## License + +ini4j is licensed under the [Apache License, Version 2.0](LICENSE.txt). By +contributing, you agree that your contribution is licensed under the same +terms. diff --git a/NOTICE.txt b/NOTICE.txt index 5013504..fbb753e 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -1,4 +1,4 @@ -Copyright 2005,2009 Ivan SZKIBA +Copyright 2005-2026 Ivan SZKIBA Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 934fd9c..211740e 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,22 @@ -# ini4j +# ini4j +[![CI](https://github.com/ini4j/ini4j/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/ini4j/ini4j/actions/workflows/ci.yml) [![Maven Central](https://img.shields.io/maven-central/v/org.ini4j/ini4j.svg?label=Maven%20Central)](https://search.maven.org/artifact/org.ini4j/ini4j) -[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) +[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE.txt) -**The Java API for handling Windows .ini files.** +ini4j is a Java library for reading and writing Windows `.ini` files. It also +includes an implementation of the `java.util.prefs.Preferences` API that is +backed by an `.ini` file, so you can keep application settings next to your +application instead of in a hidden per-user directory. -> 🚧 **MIGRATION IN PROGRESS** -> -> This project is currently migrating from [SourceForge](https://sourceforge.net/projects/ini4j/) to GitHub. -> Active work is underway to modernize the codebase, build system, and documentation for the upcoming **v0.6.0** release. +## Status ---- +The latest release on Maven Central is 0.5.4. The `main` branch is +0.6.0-SNAPSHOT: it needs Java 17 and contains a fix for CVE-2022-41404 that +0.5.4 does not have (see [Security](#security)). Version 0.6.0 has not been +released yet. -## πŸ—ΊοΈ Roadmap to v0.6.0 - -The project is being revived to support modern Java versions (17+) and fix long-standing issues. - -- [x] **Migration:** Move full SVN history to GitHub. -- [ ] **Modernization:** Refactor structure to Maven Standard Layout (`src/main/java`). -- [ ] **Build:** Modernize POM and enable GitHub Actions (Java 17 CI). -- [ ] **Security:** Fix CVE-2022-41404 (DoS vulnerability). -- [ ] **Documentation:** Launch new site at `ini4j.dev`. -- [ ] **Release:** Publish v0.6.0 to Maven Central. - -*See the [Migration Issue](https://github.com/ini4j/ini4j/issues/1) for full details and discussion.* - ---- - -## πŸ“¦ Installation - -*(Note: v0.5.4 is the current stable release on Maven Central. v0.6.0 is coming soon.)* +## Installation ```xml @@ -39,11 +26,22 @@ The project is being revived to support modern Java versions (17+) and fix long- ``` -## πŸš€ Quick Start +To try the unreleased version, install it into your local Maven repository and +depend on `0.6.0-SNAPSHOT`. This needs JDK 17: + +```sh +git clone https://github.com/ini4j/ini4j.git +cd ini4j +mvn -B clean install +``` + +## Quick start + +Read a value from a file: ```java -import org.ini4j.Ini; import java.io.File; +import org.ini4j.Ini; public class Example { public static void main(String[] args) throws Exception { @@ -54,6 +52,81 @@ public class Example { } ``` -## πŸ“œ License +Write a file: + +```java +Ini ini = new Ini(); +ini.put("server", "host", "localhost"); +ini.put("server", "port", 8080); +ini.store(new File("config.ini")); +``` + +An option value can refer to another option with `${section/option}`: + +```ini +[paths] +home = /opt/app +logs = ${paths/home}/logs +``` + +## What it can do + +- Read and write sections and options, with typed access (`int`, `boolean`, + `File`, and so on) and multi-value options. +- Keep comments: the header comment, section comments and option comments. +- Map a section to a Java bean or interface, and back. +- Use `Options` as a replacement for `java.util.Properties`. +- Expose an `.ini` file through the standard Preferences API with + `IniPreferences`. +- Read and write Windows `.reg` files and the Windows registry with `Reg`. + +The main entry points are `Ini`, `Options`, `IniPreferences` and `Reg` in the +`org.ini4j` package. + +## Security + +Variable substitution follows references such as `${paths/home}`. A file with +references that point at each other used to cause a `StackOverflowError` +(CVE-2022-41404). On `main`, resolving stops after 16 levels and throws +`CircularReferenceException`. You can change the limit with +`-Dorg.ini4j.config.maxResolveDepth=N` or +`Config.getGlobal().setMaxResolveDepth(int)`. + +To report a vulnerability, see [SECURITY.md](SECURITY.md). + +## Building + +You need JDK 17 and Maven. + +```sh +mvn -B clean verify +``` + +This compiles, runs the tests and checks formatting with Spotless. CI also +runs SpotBugs and PMD, which you can enable with `-Pci`: + +```sh +mvn -B clean verify -Pci +``` + +The repository has a dev container configuration in `.devcontainer` if you +prefer to work in a container. + +## Roadmap + +The move from SourceForge to GitHub, the Maven Standard Layout, the Java 17 +build, the CI workflow and the CVE-2022-41404 fix are done. What is left for +0.6.0 is a new project site and the release to Maven Central. Progress is +tracked in [issue #1](https://github.com/ini4j/ini4j/issues/1). + +## Contributing + +Bug reports, ideas and pull requests are welcome. Read +[CONTRIBUTING.md](CONTRIBUTING.md) first, and note that this project follows a +[code of conduct](CODE_OF_CONDUCT.md). Changes are listed in +[CHANGELOG.md](CHANGELOG.md). + +## License -Licensed under the **Apache License, Version 2.0**. +ini4j is licensed under the Apache License, Version 2.0. See +[LICENSE.txt](LICENSE.txt) and [NOTICE.txt](NOTICE.txt). diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..8afb516 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,26 @@ +# Security policy + +## Reporting a vulnerability + +Please do not open a public issue for a security problem. Use GitHub's private +reporting form instead: + + + +Say which version you tested, what you did, and what happened. A short `.ini` +file or a few lines of Java that reproduce the problem help most. ini4j is +maintained by one person in their spare time, so a reply may not be immediate. + +## Supported versions + +No released version of ini4j has the fix for CVE-2022-41404, a denial of +service caused by circular variable references such as `[a] x=${b/y}` and +`[b] y=${a/x}`. Version 0.5.4, the latest release on Maven Central, is +affected. + +The fix is on the `main` branch and will ship with 0.6.0, which has not been +released yet. Until then, build from `main` to get it. There are no plans to +backport it to 0.5.x. + +If you must stay on 0.5.4, keep untrusted input away from option values that +contain `${...}` references.