Copilot commented on code in PR #699:
URL: https://github.com/apache/commons-parent/pull/699#discussion_r3098898810
##########
.github/workflows/codeql-analysis.yml:
##########
@@ -19,68 +19,18 @@ on:
push:
branches: [ master ]
pull_request:
- # The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '33 9 * * 4'
-permissions:
- contents: read
+# Explicitly drop all permissions for security.
+permissions: { }
jobs:
- analyze:
- name: Analyze
- runs-on: ubuntu-latest
+ codeql-analysis:
+ # Differs from documentation, since this allows to test the workflow in PRs
Review Comment:
Grammar: “allows to test the workflow” is unidiomatic; consider “allows
testing the workflow” (or “allows the workflow to be tested”) for clarity.
```suggestion
# Differs from documentation, since this allows testing the workflow in
PRs
```
##########
.github/workflows/codeql-analysis-reusable.yml:
##########
@@ -0,0 +1,68 @@
+# 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: CodeQL (reusable)
+
+on:
+ workflow_call:
+ inputs:
+ languages:
+ type: string
+ description: Languages to analyze
+ default: "['actions', 'java']"
Review Comment:
`inputs.languages` is documented/used as JSON (parsed via `fromJSON`), but
the default value uses single quotes (`"['actions', 'java']"`), which is not
valid JSON and will cause `fromJSON(inputs.languages)` to fail at runtime. Use
a valid JSON array string (double quotes) for the default, and keep examples
consistent (e.g., `["actions","java"]` or `'["actions", "java"]'`).
```suggestion
default: '["actions", "java"]'
```
##########
.github/workflows/README.md:
##########
@@ -0,0 +1,76 @@
+<!---
+ 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.
+-->
+
+# Reusable Workflows
+
+This directory contains
+[reusable GitHub Actions
workflows](https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows)
+shared across Apache Commons projects. They provide a consistent and secure CI
setup without duplicating configuration in each repository.
+
+## CodeQL (`codeql-analysis-reusable.yml`)
+
+Runs a [CodeQL](https://codeql.github.com/) security analysis and uploads the
results to GitHub's
+code-scanning dashboard. A separate job is created for each analyzed language.
+
+To speed up the Java autobuild step, the workflow tries to restore a Maven
dependency cache saved by
+a prior build job. For the cache to be found, the build workflow must store it
under the key:
+
+```
+${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
+```
+
+### Inputs
+
+| Input | Type | Default | Description
|
+|-------------|--------|-------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| `languages` | string | `"['actions', 'java']"` | JSON array of [CodeQL
language
identifiers](https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-language-support)
to analyze. |
Review Comment:
The documented default for `languages` is shown as `"['actions', 'java']"`,
but that is not valid JSON (single quotes) while the workflow parses it with
`fromJSON`. Update the README to use a valid JSON array string (double quotes)
so users can copy/paste without the reusable workflow failing.
```suggestion
| `languages` | string | `"["actions", "java"]"` | JSON array of [CodeQL
language
identifiers](https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-language-support)
to analyze. |
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]