Skip to content

Commit

Permalink
Merge branch 'master' into ft/hidden-friends
Browse files Browse the repository at this point in the history
  • Loading branch information
frederic-tingaud-sonarsource authored Jun 27, 2024
2 parents 95e4c72 + 629afcc commit db60b75
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 8 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/update_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:

jobs:
update_coverage:
permissions:
id-token: write
runs-on: ubuntu-latest
env:
TMP_BRANCH: temporary/coverage_update
Expand Down Expand Up @@ -93,10 +95,17 @@ jobs:
steps.wait-for-build.outputs.conclusion != 'success'
run: exit 1

- name: get secrets
id: secrets
uses: SonarSource/vault-action-wrapper@3996073b47b49ac5c58c750d27ab4edf469401c8 # 3.0.1
with:
secrets: |
development/kv/data/slack token | slack_token;
- name: 'Notify on slack about the failure'
if: ${{ failure() }}
env:
SLACK_API_TOKEN: ${{ secrets.SLACK_API_TOKEN }}
SLACK_API_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).slack_token }}
working-directory: 'rspec/rspec-tools'
run: |
pipenv run rspec-tools notify-failure-on-slack \
Expand Down
56 changes: 56 additions & 0 deletions rspec-tools/rspec_template/single_language/secrets/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"title": "SECRET_TYPE should not be disclosed",
"type": "VULNERABILITY",
"code": {
"impacts": {
"SECURITY": "HIGH"
},
"attribute": "TRUSTWORTHY"
},
"status": "ready",
"remediation": {
"func": "Constant\/Issue",
"constantCost": "30min"
},
"tags": [
"cwe",
"cert"
],
"defaultSeverity": "Blocker",
"ruleSpecification": "RSPEC-${RSPEC_ID}",
"sqKey": "S${RSPEC_ID}",
"scope": "All",
"securityStandards": {
"CWE": [
798,
259
],
"OWASP": [
"A3"
],
"CERT": [
"MSC03-J."
],
"OWASP Top 10 2021": [
"A7"
],
"PCI DSS 3.2": [
"6.5.10"
],
"PCI DSS 4.0": [
"6.2.4"
],
"ASVS 4.0": [
"2.10.4",
"3.5.2",
"6.4.1"
],
"STIG ASD 2023-06-08": [
"V-222642"
]
},
"defaultQualityProfiles": [
"Sonar way"
],
"quickfix": "unknown"
}
48 changes: 48 additions & 0 deletions rspec-tools/rspec_template/single_language/secrets/rule.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

include::../../../shared_content/secrets/description.adoc[]

== Why is this an issue?

include::../../../shared_content/secrets/rationale.adoc[]

=== What is the potential impact?

// Optional: Give a general description of the secret and what it's used for.

Below are some real-world scenarios that illustrate some impacts of an attacker
exploiting the secret.

// Set value that can be used to refer to the type of secret in, for example:
// "An attacker can use this {secret_type} to ..."
:secret_type: secret

// Where possible, use predefined content for common impacts. This content can
// be found in the folder "shared_content/secrets/impact".

//include::../../../shared_content/secrets/impact/some_impact.adoc[]

== How to fix it

include::../../../shared_content/secrets/fix/revoke.adoc[]

include::../../../shared_content/secrets/fix/vault.adoc[]

=== Code examples

:example_secret: example_secret_value
:example_name: java-property-name
:example_env: ENV_VAR_NAME

include::../../../shared_content/secrets/examples.adoc[]

//=== How does this work?

//=== Pitfalls

//=== Going the extra mile

== Resources

include::../../../shared_content/secrets/resources/standards.adoc[]

//=== Benchmarks
4 changes: 3 additions & 1 deletion rspec-tools/rspec_tools/create_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ def _fill_multi_lang_template_files(self, rule_dir: Path, rule_number: int, lang

def _fill_single_lang_template_files(self, rule_dir: Path, rule_number: int, language: str):
common_template = self.TEMPLATE_PATH / 'single_language' / 'common'
lang_specific_template = self.TEMPLATE_PATH / 'single_language' / 'language_specific'
lang_specific_template = self.TEMPLATE_PATH / 'single_language' / language
if not Path(lang_specific_template).exists():
lang_specific_template = self.TEMPLATE_PATH / 'single_language' / 'language_specific'
copy_directory_content(common_template, rule_dir)

lang_dir = rule_dir /language
Expand Down
40 changes: 38 additions & 2 deletions rules/S6864/kubernetes/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ node failure.

=== Code examples

To avoid potential issues specify a memory limit for each container.
To avoid potential issues, either specify a memory limit for each container in a pod specification or create a resource of a kind, `LimitRange`, that sets a default memory limit for all containers in all pod specifications belonging to the same namespace.

==== Noncompliant code example

Expand All @@ -55,6 +55,18 @@ spec:
image: nginx
----

[source,yaml,diff-id=2,diff-type=noncompliant]
----
apiVersion: v1
kind: Pod
metadata:
name: example
spec:
containers:
- name: web # Noncompliant
image: nginx
----

==== Compliant solution

[source,yaml,diff-id=1,diff-type=compliant]
Expand All @@ -72,11 +84,35 @@ spec:
memory: 100Mi
----

[source,yaml,diff-id=2,diff-type=compliant]
----
apiVersion: v1
kind: LimitRange
metadata:
name: mem-limit-range
namespace: default-mem-example
spec:
limits:
- type: Container
default:
memory: 100Mi
---
apiVersion: v1
kind: Pod
metadata:
name: example
namespace: default-mem-example
spec:
containers:
- name: web
image: nginx
----

=== How does this work?

A limit can be set through the property `resources.limits.memory` of a
container. Alternatively, a default limit for a namespace can be set with
`LimitRange`.
`LimitRange` through `spec.limits[].default.memory`.

== Resources

Expand Down
7 changes: 3 additions & 4 deletions rules/S6909/java/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class DatabaseExample {
public void updateTodayOrders(Connection connection, List<Order> orders) {
Date today = java.sql.Date.valueOf(LocalDate.now());
String insertQuery = "INSERT INTO Order (id, price, executionDate) VALUES (?, ?, ?)";
PreparedStatement preparedStatement = connection.prepareStatement(SQL_INSERT);
PreparedStatement preparedStatement = connection.prepareStatement(insertQuery);
for(Order order: orders) {
preparedStatement.setString(1, order.id());
Expand All @@ -50,10 +50,9 @@ public class DatabaseExample {
public void updateTodayOrders(Connection connection, List<Order> orders) {
Date today = java.sql.Date.valueOf(LocalDate.now());
String insertQuery = "INSERT INTO Order (id, price, executionDate) VALUES (?, ?, ?)";
preparedStatement.setDate(3, today); // Compliant
PreparedStatement preparedStatement = connection.prepareStatement(SQL_INSERT);
PreparedStatement preparedStatement = connection.prepareStatement(insertQuery);
preparedStatement.setDate(3, today); // Compliant
for(Order order: orders) {
preparedStatement.setString(1, order.id());
preparedStatement.setString(2, order.price());
Expand Down

0 comments on commit db60b75

Please sign in to comment.