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

[ML] Update file data visualizer permissions #101169

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
22b84ab
[ML] Update file data visualizer permissions
jgowdyelastic Jun 2, 2021
15df2e6
adding home bundle
jgowdyelastic Jun 2, 2021
2473bcf
fixing translations
jgowdyelastic Jun 2, 2021
1e199bd
Merge branch 'master' into update-file-data-visualizer-permissions
kibanamachine Jun 8, 2021
5fd67e8
Merge remote-tracking branch 'origin/master' into update-file-data-vi…
jgowdyelastic Jun 17, 2021
8cdff37
removing home from bundles
jgowdyelastic Jun 17, 2021
988a9fa
Merge branch 'master' into update-file-data-visualizer-permissions
kibanamachine Jun 18, 2021
ef820e5
switching to current user for analysis
jgowdyelastic Jun 18, 2021
62a7868
adding find structure permission check
jgowdyelastic Jun 18, 2021
d542bf8
clean up
jgowdyelastic Jun 18, 2021
8ff3b12
updating text
jgowdyelastic Jun 18, 2021
a11b0f8
Merge branch 'master' into update-file-data-visualizer-permissions
kibanamachine Jun 21, 2021
d19e738
updating maps
jgowdyelastic Jun 21, 2021
db90076
Merge branch 'master' into update-file-data-visualizer-permissions
kibanamachine Jun 22, 2021
34518bf
Merge branch 'master' into update-file-data-visualizer-permissions
kibanamachine Jun 29, 2021
8e7c537
removing has_find_file_structure_permission endpoint
jgowdyelastic Jun 29, 2021
df2b11b
removing more code
jgowdyelastic Jun 29, 2021
d77e042
adding permission error message
jgowdyelastic Jun 29, 2021
fc9949f
renaming variable
jgowdyelastic Jun 29, 2021
3d3c2c0
adding fileUpload:analyzeFile back into ML
jgowdyelastic Jun 29, 2021
6e49678
updating error text
jgowdyelastic Jun 29, 2021
940f7b1
updating snapshots
jgowdyelastic Jun 29, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ import { isEqual } from 'lodash';
import { AboutPanel, LoadingPanel } from '../about_panel';
import { BottomBar } from '../bottom_bar';
import { ResultsView } from '../results_view';
import { FileCouldNotBeRead, FileTooLarge } from './file_error_callouts';
import {
FileCouldNotBeRead,
FileTooLarge,
FindFileStructurePermissionDenied,
} from './file_error_callouts';
import { EditFlyout } from '../edit_flyout';
import { ExplanationFlyout } from '../explanation_flyout';
import { ImportView } from '../import_view';
Expand Down Expand Up @@ -50,6 +54,7 @@ export class FileDataVisualizerView extends Component {
isExplanationFlyoutVisible: false,
bottomBarVisible: false,
hasPermissionToImport: false,
fileCouldNotBeReadPermissionError: false,
};

this.overrides = {};
Expand Down Expand Up @@ -87,6 +92,7 @@ export class FileDataVisualizerView extends Component {
fileSize: 0,
fileTooLarge: false,
fileCouldNotBeRead: false,
fileCouldNotBeReadPermissionError: false,
serverError: null,
results: undefined,
explanation: undefined,
Expand Down Expand Up @@ -182,17 +188,19 @@ export class FileDataVisualizerView extends Component {
fileCouldNotBeRead: isRetry,
});
} catch (error) {
const fileCouldNotBeReadPermissionError = error.body.statusCode === 403;
this.setState({
results: undefined,
explanation: undefined,
loaded: false,
loading: false,
fileCouldNotBeRead: true,
fileCouldNotBeReadPermissionError,
serverError: error,
});

// reload the results with the previous overrides
if (isRetry === false) {
if (isRetry === false && fileCouldNotBeReadPermissionError === false) {
this.setState({
loading: true,
loaded: false,
Expand Down Expand Up @@ -275,6 +283,7 @@ export class FileDataVisualizerView extends Component {
isExplanationFlyoutVisible,
bottomBarVisible,
hasPermissionToImport,
fileCouldNotBeReadPermissionError,
} = this.state;

const fields =
Expand All @@ -286,7 +295,12 @@ export class FileDataVisualizerView extends Component {
<div>
{mode === MODE.READ && (
<>
{!loading && !loaded && <AboutPanel onFilePickerChange={this.onFilePickerChange} />}
{!loading && !loaded && (
<AboutPanel
onFilePickerChange={this.onFilePickerChange}
disabled={!fileCouldNotBeReadPermissionError}
/>
)}

{loading && <LoadingPanel />}

Expand All @@ -296,11 +310,15 @@ export class FileDataVisualizerView extends Component {

{fileCouldNotBeRead && loading === false && (
<>
<FileCouldNotBeRead
error={serverError}
loaded={loaded}
showEditFlyout={this.showEditFlyout}
/>
{fileCouldNotBeReadPermissionError ? (
<FindFileStructurePermissionDenied />
) : (
<FileCouldNotBeRead
error={serverError}
loaded={loaded}
showEditFlyout={this.showEditFlyout}
/>
)}
<EuiSpacer size="l" />
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,26 @@ export const Explanation: FC<{ error: FindFileStructureErrorResponse }> = ({ err
</>
);
};

export const FindFileStructurePermissionDenied: FC = () => {
return (
<>
<EuiCallOut
title={
<FormattedMessage
id="xpack.dataVisualizer.file.fileErrorCallouts.findFileStructurePermissionDenied.title"
defaultMessage="Permission denied"
/>
}
color="danger"
iconType="cross"
data-test-subj="dataVisualizerFileStructurePermissionDeniedErrorCallout"
>
<FormattedMessage
id="xpack.dataVisualizer.file.fileErrorCallouts.findFileStructurePermissionDenied.description"
defaultMessage="You do not have sufficient privileges to analyze files."
Copy link
Member

Choose a reason for hiding this comment

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

I like this updated text 👍

/>
</EuiCallOut>
</>
);
};

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions x-pack/plugins/features/server/oss_features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const buildOSSFeatures = ({
privileges: {
all: {
app: ['discover', 'kibana'],
api: ['fileUpload:analyzeFile'],
Copy link
Member

Choose a reason for hiding this comment

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

I know we discussed Discover as one example of a feature that should grant this functionality, but is that the only one? If I'm reading this right, it looks like we are taking this away from the maps and ml features, which would surprise our users when they upgrade

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, failing tests have just shown that ML still needs to supply this privilege.
Maps does not as it does not use the file structure finder feature.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated in 3d3c2c0

catalogue: ['discover'],
savedObject: {
all: ['search', 'query', 'index-pattern'],
Expand Down
4 changes: 0 additions & 4 deletions x-pack/plugins/file_upload/server/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ export function fileUploadRoutes(coreSetup: CoreSetup<StartDeps, unknown>, logge
accepts: ['application/json'],
maxBytes: MAX_FILE_SIZE_BYTES,
},
tags: ['access:fileUpload:import'],
},
},
async (context, request, response) => {
Expand Down Expand Up @@ -185,9 +184,6 @@ export function fileUploadRoutes(coreSetup: CoreSetup<StartDeps, unknown>, logge
validate: {
body: schema.object({ index: schema.string() }),
},
options: {
tags: ['access:fileUpload:import'],
},
},
async (context, request, response) => {
try {
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/maps/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ export class MapsPlugin implements Plugin {
catalogue: [APP_ID],
privileges: {
all: {
api: ['fileUpload:import'],
app: [APP_ID, 'kibana'],
catalogue: [APP_ID],
savedObject: {
Expand Down
6 changes: 1 addition & 5 deletions x-pack/plugins/ml/common/types/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,7 @@ export function getPluginPrivileges() {
return {
admin: {
...privilege,
api: [
'fileUpload:import',
'fileUpload:analyzeFile',
...allMlCapabilitiesKeys.map((k) => `ml:${k}`),
],
api: ['fileUpload:analyzeFile', ...allMlCapabilitiesKeys.map((k) => `ml:${k}`)],
catalogue: [PLUGIN_ID, `${PLUGIN_ID}_file_data_visualizer`],
ui: allMlCapabilitiesKeys,
savedObject: {
Expand Down