Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Licensed to the Apache Software Foundation (ASF) under one or more

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个写action 是根据官方内容添加的, publish 需要合并后在测试.

# 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
#
# https://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.

name: "CodeQL"
on: [push, pull_request]

permissions:
contents: read

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'java' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
with:
persist-credentials: false
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@51f77329afa6477de8c49fc9c7046c15b9a4e79d # 3.29.5
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@51f77329afa6477de8c49fc9c7046c15b9a4e79d # 3.29.5

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@51f77329afa6477de8c49fc9c7046c15b9a4e79d # 3.29.5
31 changes: 31 additions & 0 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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
#
# https://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.

name: 'Dependency Review'
on: [pull_request]

permissions:
contents: read

jobs:
dependency-review:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 'Dependency Review PR'
uses: actions/dependency-review-action@da24556b548a50705dd671f47852072ea4c105d9 # v4.7.1
60 changes: 60 additions & 0 deletions .github/workflows/maven.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# 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
#
# https://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.

name: Java CI

on:
push:
branches: [ ${{ github.event.repository.default_branch }} ]
pull_request:
branches: [ ${{ github.event.repository.default_branch }} ]

Comment on lines +18 to +23

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix YAML parse error in the branches list

actionlint cannot parse the flow-style list that embeds a GitHub expression, causing the whole workflow to be rejected.
Switch to block-style so both YAML and GitHub Actions tooling accept it.

-  push:
-    branches: [ ${{ github.event.repository.default_branch }} ]
-  pull_request:
-    branches: [ ${{ github.event.repository.default_branch }} ]
+  push:
+    branches:
+      - ${{ github.event.repository.default_branch }}
+  pull_request:
+    branches:
+      - ${{ github.event.repository.default_branch }}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
on:
push:
branches: [ ${{ github.event.repository.default_branch }} ]
pull_request:
branches: [ ${{ github.event.repository.default_branch }} ]
on:
push:
branches:
- ${{ github.event.repository.default_branch }}
pull_request:
branches:
- ${{ github.event.repository.default_branch }}
🧰 Tools
🪛 actionlint (1.7.7)

19-19: could not parse as YAML: yaml: line 19: did not find expected ',' or ']'

(syntax-check)

🪛 YAMLlint (1.37.1)

[error] 20-20: syntax error: expected ',' or ']', but got '{'

(syntax)

🤖 Prompt for AI Agents
In .github/workflows/maven.yaml around lines 18 to 23, the branches list uses
flow-style with embedded GitHub expressions, causing YAML parse errors. Change
the branches list from flow-style (square brackets) to block-style (each branch
on its own line with a dash) to ensure proper parsing by actionlint and GitHub
Actions.

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
java: [ 8, 11, 17, 21 ]
experimental: [false]
include:
- java: 24
experimental: true
- java: 25-ea
experimental: true

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
- name: Build with Maven
run: mvn --errors --show-version --batch-mode --no-transfer-progress verify -e

# For Java 11, you can be more strict: -DadditionalJOption=-Xdoclint/package:-org.apache.commons.configuration2.plist
20 changes: 20 additions & 0 deletions .github/workflows/publish-github-packages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Publish package to GitHub Packages
on:
release:
types: [created]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: '24'
distribution: 'temurin'
- name: Publish package
run: mvn --batch-mode deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69 changes: 69 additions & 0 deletions .github/workflows/scorecards-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# 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
#
# https://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.

name: "Scorecards supply-chain security"

on:
branch_protection_rule:
schedule:
- cron: "30 1 * * 6" # Weekly on Saturdays
push:
branches: [ $default-branch ]
Comment on lines +22 to +23

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Undefined branches placeholder will break the trigger

$default-branch is not a GitHub Actions context or environment variable, so the workflow will try to match a literal branch with that name.
Use the repository default branch dynamically or hard-code main/master.

-    branches: [ $default-branch ]
+    # If you want it dynamic
+    branches: [ ${{ github.event.repository.default_branch }} ]
+    # …or just name it explicitly
+#   branches: [ main ]

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In .github/workflows/scorecards-analysis.yml at lines 22 to 23, the push trigger
uses an undefined placeholder `$default-branch` for branches, which will not
work as expected. Replace `$default-branch` with either the actual default
branch name like `main` or `master`, or use GitHub Actions' built-in context to
dynamically reference the default branch if supported, ensuring the workflow
triggers correctly on pushes to the intended branch.


permissions: read-all

jobs:

analysis:

name: "Scorecards analysis"
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to the code-scanning dashboard.
security-events: write
actions: read
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout

Comment on lines +25 to +39

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Over-permissive top-level permissions

permissions: read-all grants every possible read scope to every job, defeating least-privilege principles and overriding any stricter defaults you may want elsewhere.
Declare only the scopes really needed (or omit the top-level block entirely and keep the explicit job-level listing).

-permissions: read-all
+# Top-level permissions are optional; delete or scope down
+# permissions:
+#   contents: read
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
permissions: read-all
jobs:
analysis:
name: "Scorecards analysis"
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to the code-scanning dashboard.
security-events: write
actions: read
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
# Top-level permissions are optional; delete or scope down
# permissions:
# contents: read
jobs:
analysis:
name: "Scorecards analysis"
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to the code-scanning dashboard.
security-events: write
actions: read
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
🤖 Prompt for AI Agents
In .github/workflows/scorecards-analysis.yml around lines 25 to 39, remove the
top-level 'permissions: read-all' declaration as it grants excessive read access
to all jobs. Instead, rely solely on the explicit job-level permissions already
defined under the 'analysis' job to enforce least privilege and avoid overriding
stricter defaults.

steps:

- name: "Checkout code"
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # 2.4.2
with:
results_file: results.sarif
results_format: sarif
# A read-only PAT token, which is sufficient for the action to function.
# The relevant discussion: https://github.com/ossf/scorecard-action/issues/188
repo_token: ${{ secrets.GITHUB_TOKEN }}
# Publish the results for public repositories to enable scorecard badges.
# For more details: https://github.com/ossf/scorecard-action#publishing-results
publish_results: true

- name: "Upload artifact"
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: SARIF file
path: results.sarif
retention-days: 5

- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@51f77329afa6477de8c49fc9c7046c15b9a4e79d # 3.29.5
with:
sarif_file: results.sarif
13 changes: 9 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@
<modelVersion>4.0.0</modelVersion>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.4</version>
<version>1.9.5</version>
<name>Apache Commons BeanUtils</name>

<inceptionYear>2000</inceptionYear>
<description>Apache Commons BeanUtils provides an easy-to-use but flexible wrapper around reflection and introspection.</description>
<url>https://commons.apache.org/proper/commons-beanutils/</url>

<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<commons.componentid>beanutils</commons.componentid>
<commons.release.version>1.9.4</commons.release.version>
<commons.release.version>1.9.5</commons.release.version>
<commons.jira.id>BEANUTILS</commons.jira.id>
<commons.jira.pid>12310460</commons.jira.pid>
<!-- limit memory size see BEANUTILS-291; allow command-line override -->
Expand Down Expand Up @@ -90,6 +90,11 @@
<name>Apache Commons Beanutils Site</name>
<url>scm:svn:https://svn.apache.org/repos/infra/websites/production/commons/content/proper/commons-beanutils</url>
</site>
<repository>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/apache/commons-beanutils</url>
</repository>
</distributionManagement>

<developers>
Expand Down
4 changes: 4 additions & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<title>Release Notes</title>
</properties>
<body>
<release version="1.9.5" date="2025-08-07" description="The primary reason for this release is a bugfix for
CVE-2025-48734.">
<action type="add" dev="ggregory" due-to="Gary Gregory">Add org.apache.commons.beanutils.SuppressPropertiesBeanIntrospector.SUPPRESS_DECLARING_CLASS.</action>
</release>

<release version="1.9.4" date="2019-06-12" description="The primary reason for this release is a bugfix for
CVE-2014-0114. More specifically, our goal with BEANUTILS-520
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ public final void resetBeanIntrospectors() {
introspectors.clear();
introspectors.add(DefaultBeanIntrospector.INSTANCE);
introspectors.add(SuppressPropertiesBeanIntrospector.SUPPRESS_CLASS);
introspectors.add(SuppressPropertiesBeanIntrospector.SUPPRESS_DECLARING_CLASS);
}

/**
Expand Down Expand Up @@ -356,7 +357,7 @@ public void copyProperties(final Object dest, final Object orig)
* access to the property accessor method
* @throws IllegalArgumentException if <code>bean</code> is null
* @throws InvocationTargetException if the property accessor method
* throws an exception
* throws an exception
* @throws NoSuchMethodException if an accessor method for this
* propety cannot be found
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ public class SuppressPropertiesBeanIntrospector implements BeanIntrospector {
public static final SuppressPropertiesBeanIntrospector SUPPRESS_CLASS =
new SuppressPropertiesBeanIntrospector(Collections.singleton("class"));

/**
* A specialized instance which is configured to suppress the special {@code declaringClass} property of Java enums. Unintended access to the
* {@code declaringClass} property (which is common to all Java {@code enum}s) can be a security risk because it also allows access to the class loader. Adding this
* instance as {@code BeanIntrospector} to an instance of {@code PropertyUtilsBean} suppresses the {@code declaringClass} property; it can then no longer be
* accessed.
*
* @since 1.9.5
*/
public static final SuppressPropertiesBeanIntrospector SUPPRESS_DECLARING_CLASS = new SuppressPropertiesBeanIntrospector(
Collections.singleton("declaringClass"));
/** A set with the names of the properties to be suppressed. */
private final Set<String> propertyNames;

Expand Down
33 changes: 33 additions & 0 deletions src/test/java/org/apache/commons/beanutils/TestEnum.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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
*
* https://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 org.apache.commons.beanutils;

/**
* An {@code enum} test fixture.
*/
public enum TestEnum {

/** Test fixture. */
A,

/** Test fixture. */
B,

/** Test fixture. */
C
}
Loading
Loading