Skip to content

Forbidden fields are now ignored #240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 9, 2023
Merged

Forbidden fields are now ignored #240

merged 2 commits into from
Jan 9, 2023

Conversation

russgold
Copy link
Member

@russgold russgold commented Jan 5, 2023

Customer (Jose Luis Molina Dueñas) reported problems:

Requesting metrics from

metricsNameSnakeCase: true
domainQualifier: true
queries:
- JDBCServiceRuntime:
    JDBCDataSourceRuntimeMBeans:
      prefix: wls_datasource_
      key: name
      stringValues:
        state: [Running, Suspended, Shutdown, Overloaded, Unknown]

fails because the mbean contains a field, properties, which requires admin access.

Under some conditions, if a higher-level bean is filtered but no matching keys exist on one server, the request was asking for all beans.

This change attempts to fix both by cleaning up the filtering when there is no match, and by detecting an attempt to request a forbidden field and either removing it from the query if specified, or adding an excludeFields element if the containing bean is specified without values.

@russgold russgold self-assigned this Jan 5, 2023
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jan 5, 2023
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 5, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

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

95.1% 95.1% Coverage
0.0% 0.0% Duplication

@russgold russgold marked this pull request as ready for review January 5, 2023 17:00

private String getProblem(MBeanSelector selector) {
if (selector.isRequestForPrivilegedProperty())
return "You seem to have encountered a bug in the WebLogic REST API.\n" +
Copy link
Member

@rjeberhard rjeberhard Jan 6, 2023

Choose a reason for hiding this comment

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

Can this text come from a resource bundle?

Copy link
Member

Choose a reason for hiding this comment

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

Actually, nevermind. This is for an internal error. If it's easy then do it, but it's not critical.

Copy link
Member Author

Choose a reason for hiding this comment

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

It could; actually, it could probably be removed, since I know have altered the code to exclude it.

@@ -24,6 +24,10 @@
* @author Russell Gold
*/
public class ExporterConfig implements MetricsProcessor {
// Due to a bug in the WLS REST API, a query that includes this field will fail if not run with admin privileges.
// The code thus ensures that it is excluded from all queries.
private static final String[] FORBIDDEN_FIELDS = {"JDBCServiceRuntime:JDBCDataSourceRuntimeMBeans:properties"};
Copy link
Member

Choose a reason for hiding this comment

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

Just curious... Is this the only affected field or just the only one that we know about?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's the only one we've found so far. But I have written the exclusion code to make it easy to add others if we find them.

@russgold russgold merged commit f0d96ab into main Jan 9, 2023
@russgold russgold deleted the russ_fix_filter_flaws branch January 9, 2023 14:08
@russgold russgold changed the title Improve filtering: ignore subtrees with no matches, exclude forbidden… Forbidden fields are now ignored Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants