Skip to content

Commit

Permalink
[Security Solution] Remove feature flag trustedAppsByPolicyEnabled (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
academo authored Jan 10, 2022
1 parent e938f4c commit 3cca7f0
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const allowedExperimentalValues = Object.freeze({
ruleRegistryEnabled: true,
tGridEnabled: true,
tGridEventRenderedViewEnabled: true,
trustedAppsByPolicyEnabled: true,
excludePoliciesInFilterEnabled: false,
uebaEnabled: false,
disableIsolationUIPendingStatuses: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
NewPackagePolicy,
pagePathGetters,
} from '../../../../../../../fleet/public';
import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features';
import { INTEGRATIONS_PLUGIN_ID } from '../../../../../../../fleet/common';
import { useAppUrl } from '../../../../../common/lib/kibana/hooks';
import { PolicyDetailsRouteState } from '../../../../../../common/endpoint/types';
Expand Down Expand Up @@ -58,10 +57,6 @@ const WrappedPolicyDetailsForm = memo<{
const endpointDetailsLoadingError = usePolicyDetailsSelector(apiError);
const { getAppUrl } = useAppUrl();
const [, setLastUpdatedPolicy] = useState(updatedPolicy);
// TODO: Remove this and related code when removing FF
const isTrustedAppsByPolicyEnabled = useIsExperimentalFeatureEnabled(
'trustedAppsByPolicyEnabled'
);

// When the form is initially displayed, trigger the Redux middleware which is based on
// the location information stored via the `userChangedUrl` action.
Expand Down Expand Up @@ -164,63 +159,59 @@ const WrappedPolicyDetailsForm = memo<{

return (
<div data-test-subj="endpointIntegrationPolicyForm">
{isTrustedAppsByPolicyEnabled ? (
<>
<div>
<EuiText>
<h5>
<FormattedMessage
id="xpack.securitySolution.endpoint.policyDetails.artifacts.title"
defaultMessage="Artifacts"
/>
</h5>
</EuiText>
<EuiSpacer size="s" />
<FleetTrustedAppsCard
policyId={policyId}
cardSize="m"
customLink={policyTrustedAppsLink}
/>
<EuiSpacer size="s" />
<FleetIntegrationEventFiltersCard policyId={policyId} />
<EuiSpacer size="s" />
<FleetIntegrationHostIsolationExceptionsCard policyId={policyId} />
</div>
<EuiSpacer size="l" />
<div>
<EuiText>
<h5>
<>
<div>
<EuiText>
<h5>
<FormattedMessage
id="xpack.securitySolution.endpoint.policyDetails.artifacts.title"
defaultMessage="Artifacts"
/>
</h5>
</EuiText>
<EuiSpacer size="s" />
<FleetTrustedAppsCard
policyId={policyId}
cardSize="m"
customLink={policyTrustedAppsLink}
/>
<EuiSpacer size="s" />
<FleetIntegrationEventFiltersCard policyId={policyId} />
<EuiSpacer size="s" />
<FleetIntegrationHostIsolationExceptionsCard policyId={policyId} />
</div>
<EuiSpacer size="l" />
<div>
<EuiText>
<h5>
<FormattedMessage
id="xpack.securitySolution.endpoint.policyDetails.settings.title"
defaultMessage="Policy settings"
/>
</h5>
</EuiText>
<EuiSpacer size="s" />
{endpointDetailsLoadingError ? (
<EuiCallOut
title={
<FormattedMessage
id="xpack.securitySolution.endpoint.policyDetails.settings.title"
defaultMessage="Policy settings"
id="xpack.securitySolution.endpoint.policyDetails.loadError"
defaultMessage="Failed to load endpoint policy settings"
/>
</h5>
</EuiText>
<EuiSpacer size="s" />
{endpointDetailsLoadingError ? (
<EuiCallOut
title={
<FormattedMessage
id="xpack.securitySolution.endpoint.policyDetails.loadError"
defaultMessage="Failed to load endpoint policy settings"
/>
}
iconType="alert"
color="warning"
data-test-subj="endpiontPolicySettingsLoadingError"
>
{endpointDetailsLoadingError.message}
</EuiCallOut>
) : !endpointPolicyDetails ? (
<EuiLoadingSpinner size="l" className="essentialAnimation" />
) : (
<PolicyDetailsForm />
)}
</div>
</>
) : (
<PolicyDetailsForm />
)}
}
iconType="alert"
color="warning"
data-test-subj="endpiontPolicySettingsLoadingError"
>
{endpointDetailsLoadingError.message}
</EuiCallOut>
) : !endpointPolicyDetails ? (
<EuiLoadingSpinner size="l" className="essentialAnimation" />
) : (
<PolicyDetailsForm />
)}
</div>
</>
</div>
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ import { EuiCallOut, EuiLoadingSpinner, EuiPageTemplate } from '@elastic/eui';
import { usePolicyDetailsSelector } from './policy_hooks';
import { policyDetails, agentStatusSummary, apiError } from '../store/policy_details/selectors';
import { AgentsSummary } from './agents_summary';
import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features';
import { PolicyTabs } from './tabs';
import { AdministrationListPage } from '../../../components/administration_list_page';
import { PolicyFormLayout } from './policy_forms/components';
import {
BackToExternalAppButton,
BackToExternalAppButtonProps,
Expand All @@ -26,10 +24,6 @@ import { useAppUrl } from '../../../../common/lib/kibana';
import { APP_UI_ID } from '../../../../../common/constants';

export const PolicyDetails = React.memo(() => {
// TODO: Remove this and related code when removing FF
const isTrustedAppsByPolicyEnabled = useIsExperimentalFeatureEnabled(
'trustedAppsByPolicyEnabled'
);
const { state: routeState = {} } = useLocation<PolicyDetailsRouteState>();
const { getAppUrl } = useAppUrl();

Expand Down Expand Up @@ -106,13 +100,8 @@ export const PolicyDetails = React.memo(() => {
);
}

// TODO: Remove this and related code when removing FF
if (isTrustedAppsByPolicyEnabled) {
return <PolicyTabs />;
}

return <PolicyFormLayout />;
}, [isTrustedAppsByPolicyEnabled, policyApiError, policyItem]);
return <PolicyTabs />;
}, [policyApiError, policyItem]);

return (
<AdministrationListPage
Expand All @@ -122,7 +111,7 @@ export const PolicyDetails = React.memo(() => {
headerBackComponent={backToEndpointList}
actions={policyApiError ? undefined : headerRightContent}
restrictWidth={true}
hasBottomBorder={!isTrustedAppsByPolicyEnabled} // TODO: Remove this and related code when removing FF
hasBottomBorder={false}
>
{pageBody}
</AdministrationListPage>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ describe('when rendering the PolicyTrustedAppsList', () => {
});

mockedApis = policyDetailsPageAllApiHttpMocks(appTestContext.coreStart.http);
appTestContext.setExperimentalFlag({ trustedAppsByPolicyEnabled: true });
waitForAction = appTestContext.middlewareSpy.waitForAction;
componentRenderProps = {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import { useTestIdGenerator } from '../../../../components/hooks/use_test_id_gen
import { useLicense } from '../../../../../common/hooks/use_license';
import { isGlobalEffectScope } from '../../state/type_guards';
import { NewTrustedApp } from '../../../../../../common/endpoint/types';
import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features';

export type CreateTrustedAppFlyoutProps = Omit<EuiFlyoutProps, 'hideCloseButton'>;
export const CreateTrustedAppFlyout = memo<CreateTrustedAppFlyoutProps>(
Expand Down Expand Up @@ -116,10 +115,6 @@ export const CreateTrustedAppFlyout = memo<CreateTrustedAppFlyoutProps>(
[dispatch, formValues]
);

const isTrustedAppsByPolicyEnabled = useIsExperimentalFeatureEnabled(
'trustedAppsByPolicyEnabled'
);

const [wasByPolicy, setWasByPolicy] = useState(!isGlobalEffectScope(formValues.effectScope));
// set initial state of `wasByPolicy` that checks if the initial state of the exception was by policy or not
useEffect(() => {
Expand All @@ -133,21 +128,8 @@ export const CreateTrustedAppFlyout = memo<CreateTrustedAppFlyoutProps>(
}, [formValues]);

const showExpiredLicenseBanner = useMemo(() => {
return (
isTrustedAppsByPolicyEnabled &&
!isPlatinumPlus &&
isEditMode &&
wasByPolicy &&
(!isGlobal || isFormDirty)
);
}, [
isTrustedAppsByPolicyEnabled,
isPlatinumPlus,
isEditMode,
isGlobal,
isFormDirty,
wasByPolicy,
]);
return !isPlatinumPlus && isEditMode && wasByPolicy && (!isGlobal || isFormDirty);
}, [isPlatinumPlus, isEditMode, isGlobal, isFormDirty, wasByPolicy]);

// If there was a failure trying to retrieve the Trusted App for edit item,
// then redirect back to the list ++ show toast message.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {
hasSimpleExecutableName,
} from '../../../../../../common/endpoint/service/trusted_apps/validations';

import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features';
import {
isGlobalEffectScope,
isMacosLinuxTrustedAppCondition,
Expand Down Expand Up @@ -238,10 +237,6 @@ export const CreateTrustedAppForm = memo<CreateTrustedAppFormProps>(

const dataTestSubj = formProps['data-test-subj'];

const isTrustedAppsByPolicyEnabled = useIsExperimentalFeatureEnabled(
'trustedAppsByPolicyEnabled'
);

const isPlatinumPlus = useLicense().isPlatinumPlus();

const isGlobal = useMemo(() => {
Expand Down Expand Up @@ -519,7 +514,7 @@ export const CreateTrustedAppForm = memo<CreateTrustedAppFormProps>(
value={trustedApp.description}
onChange={handleDomChangeEvents}
fullWidth
compressed={isTrustedAppsByPolicyEnabled}
compressed
maxLength={256}
data-test-subj={getTestId('descriptionField')}
/>
Expand Down Expand Up @@ -577,7 +572,7 @@ export const CreateTrustedAppForm = memo<CreateTrustedAppFormProps>(
data-test-subj={getTestId('conditionsBuilder')}
/>
</EuiFormRow>
{isTrustedAppsByPolicyEnabled && showAssignmentSection ? (
{showAssignmentSection ? (
<>
<EuiHorizontalRule />
<EuiFormRow fullWidth={fullWidth} data-test-subj={getTestId('policySelection')}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,11 @@ import { HttpFetchOptions, HttpFetchOptionsWithPath } from 'kibana/public';
import { isFailedResourceState, isLoadedResourceState } from '../state';
import { forceHTMLElementOffsetWidth } from '../../../components/effected_policy_select/test_utils';
import { toUpdateTrustedApp } from '../../../../../common/endpoint/service/trusted_apps/to_update_trusted_app';
import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features';
import { licenseService } from '../../../../common/hooks/use_license';
import { FoundExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types';
import { EXCEPTION_LIST_ITEM_URL } from '@kbn/securitysolution-list-constants';
import { trustedAppsAllHttpMocks } from '../../mocks';

// TODO: remove this mock when feature flag is removed
jest.mock('../../../../common/hooks/use_experimental_features');
const useIsExperimentalFeatureEnabledMock = useIsExperimentalFeatureEnabled as jest.Mock;

jest.mock('../../../../common/hooks/use_license', () => {
const licenseServiceInstance = {
isPlatinumPlus: jest.fn(),
Expand Down Expand Up @@ -173,7 +168,6 @@ describe('When on the Trusted Apps Page', () => {
describe('the license is downgraded to gold or below and the user is editing a per policy TA', () => {
beforeEach(async () => {
(licenseService.isPlatinumPlus as jest.Mock).mockReturnValue(false);
useIsExperimentalFeatureEnabledMock.mockReturnValue(true);

const originalFakeTrustedAppProvider = getFakeTrustedApp.getMockImplementation();
getFakeTrustedApp.mockImplementation(() => {
Expand All @@ -198,7 +192,6 @@ describe('When on the Trusted Apps Page', () => {
describe('the license is downgraded to gold or below and the user is adding a new TA', () => {
beforeEach(async () => {
(licenseService.isPlatinumPlus as jest.Mock).mockReturnValue(false);
useIsExperimentalFeatureEnabledMock.mockReturnValue(true);

const originalFakeTrustedAppProvider = getFakeTrustedApp.getMockImplementation();
getFakeTrustedApp.mockImplementation(() => {
Expand Down Expand Up @@ -467,7 +460,6 @@ describe('When on the Trusted Apps Page', () => {
});

it('should have list of policies populated', async () => {
useIsExperimentalFeatureEnabledMock.mockReturnValue(true);
const resetEnv = forceHTMLElementOffsetWidth();
const renderResult = await renderAndClickAddButton();
act(() => {
Expand Down Expand Up @@ -700,23 +692,6 @@ describe('When on the Trusted Apps Page', () => {
expect(flyoutAddButton.disabled).toBe(true);
});
});

describe('and there is a feature flag for agents policy', () => {
it('should hide agents policy if feature flag is disabled', async () => {
useIsExperimentalFeatureEnabledMock.mockReturnValue(false);
const renderResult = await renderAndClickAddButton();
expect(
renderResult.queryByTestId('addTrustedAppFlyout-createForm-policySelection')
).toBeNull();
});
it('should display agents policy if feature flag is enabled', async () => {
useIsExperimentalFeatureEnabledMock.mockReturnValue(true);
const renderResult = await renderAndClickAddButton();
expect(
renderResult.queryByTestId('addTrustedAppFlyout-createForm-policySelection')
).toBeTruthy();
});
});
});

describe('and there are no trusted apps', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,9 @@ import { EmptyState } from './components/empty_state';
import { SearchExceptions } from '../../../components/search_exceptions';
import { BackToExternalAppButton } from '../../../components/back_to_external_app_button';
import { ListPageRouteState } from '../../../../../common/endpoint/types';
import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features';
import { ManagementPageLoader } from '../../../components/management_page_loader';

export const TrustedAppsPage = memo(() => {
const isTrustedAppsByPolicyEnabled = useIsExperimentalFeatureEnabled(
'trustedAppsByPolicyEnabled'
);
const dispatch = useDispatch<Dispatch<AppAction>>();
const { state: routeState } = useLocation<ListPageRouteState | undefined>();
const location = useTrustedAppsSelector(getCurrentLocation);
Expand Down Expand Up @@ -120,7 +116,7 @@ export const TrustedAppsPage = memo(() => {
defaultValue={location.filter}
onSearch={handleOnSearch}
placeholder={SEARCH_TRUSTED_APP_PLACEHOLDER}
hasPolicyFilter={isTrustedAppsByPolicyEnabled}
hasPolicyFilter={true}
policyList={policyList}
defaultExcludedPolicies={location.excluded_policies}
defaultIncludedPolicies={location.included_policies}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/security_solution/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const configSchema = schema.object({
* @example
* xpack.securitySolution.enableExperimental:
* - someCrazyFeature
* - trustedAppsByPolicyEnabled
* - someEvenCrazierFeature
*/
enableExperimental: schema.arrayOf(schema.string(), {
defaultValue: () => [],
Expand Down
2 changes: 0 additions & 2 deletions x-pack/test/security_solution_endpoint/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
// always install Endpoint package by default when Fleet sets up
`--xpack.fleet.packages.0.name=endpoint`,
`--xpack.fleet.packages.0.version=latest`,
// TODO: Remove feature flags once we're good to go
'--xpack.securitySolution.enableExperimental=["trustedAppsByPolicyEnabled"]',
],
},
layout: {
Expand Down

0 comments on commit 3cca7f0

Please sign in to comment.