Skip to content
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

[File upload] Migrate routing to NP & add route validation #52313

Merged
merged 28 commits into from
Feb 6, 2020

Conversation

kindsun
Copy link
Contributor

@kindsun kindsun commented Dec 5, 2019

Adds validation for file_upload route /api/fileupload/import for both initial index creation and subsequent index population using the NP router and schema validation

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Aaron Caldwell added 2 commits December 23, 2019 16:27
…-validation

# Conflicts:
#	x-pack/legacy/plugins/file_upload/server/plugin.js
#	x-pack/legacy/plugins/file_upload/server/routes/file_upload.js
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Aaron Caldwell added 19 commits December 26, 2019 08:49
const { appName, index, data, settings, mappings, ingestPipeline } = indexingDetails;

return await httpService({
url: `${apiBasePath}/fileupload/import${paramString}`,
url: `/api/fileupload/import`,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using NP internal fetch, it's no longer necessary to prepend a basepath

method: 'POST',
...(query ? { query }: {}),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We were appending this to the request string. Add here as a query instead when it exists

@kindsun kindsun marked this pull request as ready for review February 3, 2020 15:39
@kindsun kindsun added release_note:skip Skip the PR/issue when compiling release notes v7.7.0 and removed v7.6.0 labels Feb 3, 2020
@kindsun kindsun changed the title [File upload] File upload import route validation [File upload] Migrate routing to NP & add route validation Feb 3, 2020
@@ -17,11 +14,10 @@ export async function http(options) {
});
}
const url = options.url || '';
const headers = addSystemApiHeader({
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI you should be passing the asSystemRequest option to http.fetch if you still need this. That said, I'm not sure this request should be a system request. That flag is mostly used to bypass logic like session expiration or unauthorized responses that should redirect to the login page.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good to know. I don't think we'd want to treat it as a system request since eventually we'll want it to redirect to login if needed (i.e.- not bypass the logic that checks auth, etc.). So, sounds like the changes in place make sense?

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@thomasneirynck thomasneirynck left a comment

Choose a reason for hiding this comment

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

tested in chrome. lgtm from Maps-end.

@kindsun kindsun merged commit fabb28d into elastic:master Feb 6, 2020
kindsun pushed a commit to kindsun/kibana that referenced this pull request Feb 6, 2020
…2313)

* Cursory validation

* Handle empty data arrays and settings conditionally

* Set validation defaults. Move logic to routes folder and separate for testing

* Move plugin init back into routes folder. Syntax updates

* Migrate router to NP

* Use new np router and fetch. Add placeholder schema validation

* Override default 'maxBytes'

* Body with first-level schema keys in place

* Add conditional validation of mappings, data and settings. Clean up old joi code

* Ensure query is handled correctly on both sides. Iron out decision logic on server-side

* Move conditional validation to first step in payload handling

* Update http_service to work with latest NP changes on master

* Some reorg. Only update telemetry if no errors

* Clean up

* Test file upload validation logic

* Linting

* Review feedback. Remove unneeded apiBasePath var

* Pass entire req object with through to ES, not just the validated fields
jloleysens added a commit to jloleysens/kibana that referenced this pull request Feb 7, 2020
…b.com:jloleysens/kibana into console/feature/text-objects-in-saved-objects

* 'console/feature/text-objects-in-saved-objects' of github.com:jloleysens/kibana: (103 commits)
  fix auto closing new vis modal when navigating to lens or when navigating away with browser history (elastic#56998)
  TS of esKuery\node_types  (elastic#56857)
  Kibana app migration: Move static code dependencies into kibana_legacy plugin, part 1 (elastic#56408)
  Retry ES API calls that fail with 410/Gone (elastic#56950)
  [APM] Show missing permissions message to the user on the Services overview (elastic#56374)
  Fixing flaky CI tests for custom appRoutes (elastic#55763)
  [State Management][Docs] State syncing utils docs (elastic#56479)
  [Index management] Remove index mapper setting in tests (elastic#57066)
  Exposed common EuiExpressions to separate components be able to reuse for building new for Alert Types  (elastic#56466)
  [SIEM] update url state between page if date is relative (elastic#56813)
  fix for chart_types test (elastic#57056)
  chore(NA): remove compress from dll minimizer (elastic#57023)
  [File upload] Migrate routing to NP & add route validation (elastic#52313)
  Adding docs for grouped nav advanced setting (elastic#57013)
  Use i18n titles for field formatters, human names for numeral locales (elastic#56348)
  [Maps] Remove EMS catalogue url from docs (elastic#57020)
  [Endpoint] ERT-82 ERT-83 ERT-84: Alert list API with pagination (elastic#56538)
  [DOCS] Adds Apple notarization info to install doc (elastic#57042)
  [ML] New Platform server shim: update results service routes to use new platform router (elastic#56886)
  Fix typo on detection engine rule (elastic#56993)
  ...
kindsun pushed a commit that referenced this pull request Feb 7, 2020
…57063)

* Cursory validation

* Handle empty data arrays and settings conditionally

* Set validation defaults. Move logic to routes folder and separate for testing

* Move plugin init back into routes folder. Syntax updates

* Migrate router to NP

* Use new np router and fetch. Add placeholder schema validation

* Override default 'maxBytes'

* Body with first-level schema keys in place

* Add conditional validation of mappings, data and settings. Clean up old joi code

* Ensure query is handled correctly on both sides. Iron out decision logic on server-side

* Move conditional validation to first step in payload handling

* Update http_service to work with latest NP changes on master

* Some reorg. Only update telemetry if no errors

* Clean up

* Test file upload validation logic

* Linting

* Review feedback. Remove unneeded apiBasePath var

* Pass entire req object with through to ES, not just the validated fields
majagrubic pushed a commit to majagrubic/kibana that referenced this pull request Feb 10, 2020
…2313)

* Cursory validation

* Handle empty data arrays and settings conditionally

* Set validation defaults. Move logic to routes folder and separate for testing

* Move plugin init back into routes folder. Syntax updates

* Migrate router to NP

* Use new np router and fetch. Add placeholder schema validation

* Override default 'maxBytes'

* Body with first-level schema keys in place

* Add conditional validation of mappings, data and settings. Clean up old joi code

* Ensure query is handled correctly on both sides. Iron out decision logic on server-side

* Move conditional validation to first step in payload handling

* Update http_service to work with latest NP changes on master

* Some reorg. Only update telemetry if no errors

* Clean up

* Test file upload validation logic

* Linting

* Review feedback. Remove unneeded apiBasePath var

* Pass entire req object with through to ES, not just the validated fields
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.

5 participants