Skip to content

Conversation

@berezovskyi
Copy link
Contributor

@berezovskyi berezovskyi commented Dec 11, 2021

Description

As you know, https://blog.sonatype.com/a-new-0-day-log4j-vulnerability-discovered-in-the-wild is a big problem for the ecosystem. We are not using v2 of Log4j and are not affected but I wanted to take a bit of time to fully remove remnants of Log4j use in Lyo. As you know, Lyo uses SLF4J API in all SDK libraries and SLF4J + SimpleLogger in the webapps we ship.

Another thing this PR does is introduce the org.eclipse.lyo.core.utils.marshallers.LyoConfigUtil class with helper methods to scan the environment for a property. For example, if you are looking for the port property in the org.eclipse.lyo.oslc4j.core.servlet.ServletListener instance, we want to check these places in the order of priority:

  1. LYO_PORT environment variable. This is the new override mechanism for containerized environments.
  2. org.eclipse.lyo.oslc4j.core.servlet System (JVM) property. This is the old override mechanism for multitenant application server environments.
  3. org.eclipse.lyo.oslc4j.core.servlet Servlet Context parameter. This is the default configuration mechanism for Lyo.

org.eclipse.lyo.core.utils.marshallers.LyoConfigUtil#getOslcConfigProperty does exactly that, while org.eclipse.lyo.core.utils.marshallers.LyoConfigUtil#getOslcConfigPropertyNoContext represents a fallback mechanism only looking in (1) and (2) in case it must be invoked from a place where a ServletContext reference is not available.

However, after getting the oslc4j-registry app to run, I realized it only contains a CF only on a ServiceProvider level. My old impression was that it allows to run a single registry where mutliple SP Catalogs can be registered with the "registry" SP Catalog. In light of this discovery, I propose to mark oslc4j-registry for removal in Lyo 5.0. In current form, it's not much more than a demo app and a default output from Lyo Designer has more user-friendly look and features out of the box.

Finally, oslc4j-wink seems to have only 2 useful things:

  • OslcResourceShapeResource for reuse by Wink-based OSLC Servers. We don't support Wink any more and Lyo Designer supports much more feature-rich shape resource support (e.g. Shape HTML tables like in the OSLC specs, even for custom resources).
  • org.eclipse.lyo.oslc4j.client.OslcRestClient. This client was long replaced by the (now obsolete) org.eclipse.lyo.client.oslc.OslcClient. Modern apps should use one of the new clients via the org.eclipse.lyo.client.IOslcClient interface.

With this in mind, I propose to mark the org.eclipse.lyo.oslc4j.client.OslcRestClient deprecated immediately (done in this PR) and also schedule oslc4j-wink for full removal from Lyo in 5.0.

Checklist

  • This PR adds an entry to the CHANGELOG. See https://keepachangelog.com/en/1.0.0/ for instructions. Minor edits are exempt.
  • This PR was tested on at least one Lyo OSLC server or adds unit/integration tests.
  • This PR does NOT break the API
  • maven enforcer rule added to <exclude>log4j:log4j</exclude>

@berezovskyi
Copy link
Contributor Author

Discussed with Jad. Andrew will

  • move the config code to org.eclipse.lyo.oslc4j.core.OSLC4JUtils
  • remove the registry and wink modules

@berezovskyi berezovskyi changed the title Get it of Log4j and extract env/system/context config logic into LyoConfigUtil Extract env/system/context config logic into LyoConfigUtil Feb 15, 2022
@berezovskyi berezovskyi force-pushed the b-registry branch 2 times, most recently from 4d6ec16 to efbc772 Compare April 9, 2022 16:38
@sonarqubecloud
Copy link

sonarqubecloud bot commented May 5, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 7 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@berezovskyi berezovskyi added this to the 5.1 milestone May 9, 2022
@berezovskyi
Copy link
Contributor Author

Fails due to #284, we should instead move this code to a new module, e.g. org.eclipse.lyo:lyo-server-utils because we don't want core utils to bring back the Servlet dependency.

@github-actions github-actions bot force-pushed the b-registry branch 3 times, most recently from b4956bb to 25e6482 Compare April 27, 2023 20:53
@berezovskyi berezovskyi modified the milestones: 5.1, 5.2 Jun 30, 2023
@berezovskyi berezovskyi changed the title Extract env/system/context config logic into LyoConfigUtil feat: Extract env/system/context config logic into LyoConfigUtil Jun 30, 2023
@github-actions github-actions bot force-pushed the b-registry branch 2 times, most recently from 70ed956 to 1aab254 Compare July 14, 2023 07:43
@github-actions github-actions bot force-pushed the b-registry branch 2 times, most recently from 3e802c4 to 8454ba0 Compare August 5, 2023 07:43
@berezovskyi berezovskyi modified the milestones: 5.2, 6.0 Aug 11, 2023
@berezovskyi berezovskyi requested review from Copilot and removed request for jadelkhoury April 4, 2025 20:50

This comment was marked as outdated.

@Jad-el-khoury Jad-el-khoury self-requested a review July 28, 2025 16:43
@berezovskyi
Copy link
Contributor Author

berezovskyi commented Jul 28, 2025

eclipse-lyo/lyo.designer#295 was just merged and involves opening up the static method that this PR refactors.

Would be good to merge it before 7.0

* @param klass Class of the ServletListener
* @return value, if found, from ENV, JVM, or Servlet Context (in this order)
*/
public static String getOslcConfigProperty(
Copy link
Contributor Author

@berezovskyi berezovskyi Aug 9, 2025

Choose a reason for hiding this comment

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

Reflecting on this, I have two remarks:

The time of hosting 10s of adaptors in a single large JEE server is over, we can expect no clashes with other Lyo applications (not sure about RCP-hosted OSGi extensions using multiple Lyo servers - @jhemm2 are you using Lyo in this manner?). We still need to distinguish Lyo props from any other props user code might rely. Instead of co.oslc.refimpl.am.gen.servlet.cors.friends, we can do org.eclipse.lyo.cors.friend.

We should also align ourselves on https://microprofile.io/specifications/microprofile-config-2/ if possible. Ideally, we want to adopt it wholesale. Otherwise, we want to follow their rules, at least. This may involve a bit of a breaking change - they suggest to map the org.eclipse.lyo.cors.friend (btw, I think we should call it friends instead of friend) prop to the ORG_ECLIPSE_LYO_CORS_FRIEND unlike our LYO_CORS_FRIEND.

I am not against making a breaking change in 7.0, but we should have a definitive audit of all existing props in use and a migration path. @Jad-el-khoury if you think the breaking changes are not worth it, I am also OK to keep prop naming as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My preliminary analysis points at the following servlet props being in use in web.xml files:

  • baseurl
  • host
  • port
  • scheme
  • store.query
  • store.update

And these ones I suspect to be non-standard:

  • prorDataDir
  • repository.dir
  • root.repository.dir

@berezovskyi berezovskyi requested a review from Copilot August 9, 2025 20:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces the LyoConfigUtil class to centralize configuration property lookup across environment variables, JVM properties, and servlet context parameters, while also performing cleanup tasks including Log4j remnant removal and deprecating legacy client code.

  • Extract configuration logic into LyoConfigUtil with prioritized property lookup
  • Add new lyo-server-common module with LyoAppConfiguration record
  • Clean up logging configuration and deprecate OslcRestClient

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
core/oslc4j-utils/src/main/java/org/eclipse/lyo/core/utils/marshallers/LyoConfigUtil.java New utility class providing centralized configuration property lookup with environment/JVM/context priority
server/lyo-server-common/src/main/java/org/eclipse/lyo/server/common/LyoAppConfiguration.java New configuration record for Lyo server applications
server/lyo-server-common/pom.xml New Maven module for common server utilities
Various simplelogger.properties files Updated logging configurations with reasonable defaults for dependencies
pom.xml files Module structure updates and dependency management changes

@@ -0,0 +1,116 @@
package org.eclipse.lyo.core.utils.marshallers;
Copy link

Copilot AI Aug 9, 2025

Choose a reason for hiding this comment

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

The class lacks a copyright header and class-level documentation. Add the standard Eclipse copyright header and document the class purpose, usage patterns, and examples.

Copilot uses AI. Check for mistakes.
@berezovskyi
Copy link
Contributor Author

@oslc-bot /test-all

@oslc-bot
Copy link

oslc-bot commented Nov 29, 2025

Downstream Build Status

Repository Lyo CI Job state Workflow
oslc-op/refimpl 🔴 Fail completed Link
oslc/lyo-samples ✅ Pass completed Link
oslc/promcode-lyo-server 🔴 Fail completed Link

@berezovskyi
Copy link
Contributor Author

@oslc-bot /test-all

@oslc-bot
Copy link

oslc-bot commented Dec 22, 2025

Downstream Build Status

Repository Lyo CI Job state Workflow
oslc-op/refimpl ✅ Pass completed Link
oslc/lyo-samples ✅ Pass completed Link
oslc/promcode-lyo-server ✅ Pass completed Link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants