Skip to content

Make to behave all unsupported processors in the same way. #269

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
57 changes: 57 additions & 0 deletions spec/integration/elastic_integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1481,4 +1481,61 @@ def path; @path; end
end
end

context '#unsupported processors' do
let(:settings) {
super().merge(
"ssl_certificate_authorities" => "spec/fixtures/test_certs/root.crt"
)
}

unsupported_processors = {
'set_security_user' =>
'{
"set_security_user": {
"field": "user"
}
}',
'inference' =>
'{
"inference": {
"model_id": "model_deployment_for_inference",
"input_output": [{"input_field": "content", "output_field": "content_embedding"}]
}
}',
'enrich' =>
'{
"enrich": {
"policy_name": "enrich_policy_name",
"field": "source_field",
"target_field": "target_field"
}
}'
}

before(:each) do
subject.register
end

shared_examples 'processor failure' do
it 'adds failure tag to metadata' do
events = [LogStash::Event.new(
"message" => "55.3.244.1 GET /index.html 15824 0.043",
"data_stream" => data_stream
)]

subject.multi_filter(events).each do |event|
failure_reason = event.get("[@metadata][_ingest_pipeline_failure]")
expect(failure_reason).to be_truthy
end
end
end

unsupported_processors.each do |name, config|
describe "with #{name} processor" do
let(:pipeline_processor) { config }
include_examples 'processor failure'
end
end
end

end
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import co.elastic.logstash.api.Event;
import co.elastic.logstash.api.FilterMatchListener;
import co.elastic.logstash.filters.elasticintegration.ingest.RedactPlugin;
import co.elastic.logstash.filters.elasticintegration.ingest.SetSecurityUserProcessor;
import co.elastic.logstash.filters.elasticintegration.ingest.SingleProcessorIngestPlugin;
import co.elastic.logstash.filters.elasticintegration.resolver.CacheReloadService;
import co.elastic.logstash.filters.elasticintegration.resolver.CachingResolver;
Expand All @@ -33,7 +32,6 @@
import org.elasticsearch.painless.PainlessPlugin;
import org.elasticsearch.painless.PainlessScriptEngine;
import org.elasticsearch.painless.spi.PainlessExtension;
import org.elasticsearch.painless.spi.Whitelist;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not used anywhere.

import org.elasticsearch.plugins.ExtensiblePlugin;
import org.elasticsearch.plugins.IngestPlugin;
import org.elasticsearch.script.IngestConditionalScript;
Expand Down Expand Up @@ -128,7 +126,6 @@ public EventProcessorBuilder() {
org.elasticsearch.ingest.common.UriPartsProcessor.TYPE));
this.addProcessorsFromPlugin(IngestUserAgentPlugin::new);
this.addProcessorsFromPlugin(RedactPlugin::new);
this.addProcessor(SetSecurityUserProcessor.TYPE, SetSecurityUserProcessor.Factory::new);
Copy link
Member

Choose a reason for hiding this comment

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

I don't see any code references to set_security_user in elastic/integrations, and it has never been in our published list of supported processors.

I am +1 to deleting it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yup, we have unsupported processors scan automation and so far not appeared.

}

// event -> pipeline name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V.
* under one or more contributor license agreements. Licensed under the
* Elastic License 2.0; you may not use this file except in compliance
* with the Elastic License 2.0.
*/
package co.elastic.logstash.filters.elasticintegration.ingest;

import org.elasticsearch.cluster.metadata.ProjectId;
import org.elasticsearch.ingest.AbstractProcessor;
import org.elasticsearch.ingest.IngestDocument;
import org.elasticsearch.ingest.Processor;

import java.util.Map;

public class SetSecurityUserProcessor extends AbstractProcessor {

public static final String TYPE = "set_security_user";

private SetSecurityUserProcessor(String tag, String description) {
super(tag, description);
}


@Override
public IngestDocument execute(IngestDocument ingestDocument) throws Exception {
// within Logstash, the set_security_user processor is a no-op
return ingestDocument;
}

@Override
public String getType() {
return TYPE;
}

public static final class Factory implements Processor.Factory {

@Override
public SetSecurityUserProcessor create(Map<String, Processor.Factory> registry, String processorTag,
String description, Map<String, Object> config, ProjectId projectId) {
String[] supportedConfigs = {"field", "properties"};
for (String cfg : supportedConfigs) {
config.remove(cfg);
}
return new SetSecurityUserProcessor(processorTag, description);
}
}
}