export type ActionAccessLevel = 'read' | 'write' | 'list' | 'tagging' | 'permissions'; export declare const allActionAccessLevels: ActionAccessLevel[]; export interface ShrinkOptions { iterations: number; removeSids: boolean; levels: ActionAccessLevel[]; } /** * Shrink the list of desired patterns minus the excluded patterns to the smallest list of patterns * that still includes the actions you want and only the actions you want. * * This will create a Target Set of actions that match the patterns in {@link desiredPatterns}, and do * not match any pattern in {@link excludedPatterns}. * * It will then derive the list of wildcard patterns that match the Target Set and no other actions. * * @param desiredPatterns the list of patterns you want to include, e.g. ['s3:Get*', 's3:PutObject', 's3:*Tag*'] * @param iterations the number of iterations to run the shrink operations * @returns the smallest list of patterns that will match only the actions specified by desiredPatterns and not match any of the excludedPatterns or any actions not specified by desiredPatterns. */ export declare function shrink(desiredPatterns: string[], shrinkOptions?: Partial): Promise; /** * Map an array of service:action strings to just the action * * @param actions the array of service:action strings such as ['s3:GetObject', 'ec2:DescribeInstances'] * @returns an array of just the action strings such as ['GetObject', 'DescribeInstances'] */ export declare function mapActions(actions: string[]): string[]; /** * Groups an array of service:action strings by service * * Returns a map of service to an object with two arrays: withService and withoutService * * withService contains the full service:action strings * * withoutService contains just the action strings * * @param actions the array of service:action strings such as ['s3:GetObject', 'ec2:DescribeInstances'] * @returns a map of service to an object with two arrays: withService and withoutService */ export declare function groupActionsByService(actions: string[]): Map; /** * Shrink a list of desired actions to the smallest number of patterns that match the desired actions * from the possible actions and no other actions. * * @param desiredActions the list of actions you want to include * @param possibleActions the list of actions that are possible * @param iterations the number of iterations to run the shrink operations * @returns the smallest list of patterns that when compared to possibleActions will match only the desiredActions and no others */ export declare function shrinkResolvedList(desiredActions: string[], possibleActions: string[], actionsToNotShrink: Set, iterations: number): string[]; /** * Shrink the list of desired actions for while excluding the undesired actions * * @param desiredActions the list of actions you want to include, can be a mix of full actions and wildcards * @param undesiredActions the list of actions you want to exclude no matter what * @param deep if true, will shrink based on all common sequences, otherwise will only shrink based on the most common sequence * @returns the smallest list of actions that will match only the desiredActions and not match any of the undesiredActions or any actions not specified by desiredActions. */ export declare function shrinkIteration(desiredActions: string[], undesiredActions: string[], actionsToNotShrink: Set, deep: boolean): string[]; /** * Reduces a single action into a smaller number of parts by replace one part at a time with an asterisk * and validating that there are no undesired actions that match the new action * * @param desiredAction the action to reduce * @param sequence the sequence to reduce the action by * @param undesiredActions the list of actions that should not match the reduced action * @returns the reduced action with as many parts replaced with asterisks as possible while still matching the desired actions and not matching any of the undesired actions */ export declare function reduceAction(desiredAction: string, sequence: string, undesiredActions: string[]): string; /** * Consolidate multiple consecutive asterisks into a single asterisk * * @param wildcardAction the action to collapse * @returns the action with consecutive asterisks collapsed into a single asterisk */ export declare function collapseAsterisks(wildcardAction: string): string; /** * Convert a wildcard action into a regular expression * * @param wildcardAction the wildcard action to convert * @returns a regular expression that will match the wildcard action */ export declare function regexForWildcardAction(wildcardAction: string): RegExp; /** * Checks to see if a wildcard action matches any of the strings in a list * * @param wildcardAction the wildcard action to check * @param strings the list of strings to check against * @returns true if the wildcard action matches any of the strings */ export declare function wildcardActionMatchesAnyString(wildcardAction: string, strings: string[]): boolean; /** * Split an IAM Action into parts based on capital letters and asterisks * For a new part to start there must be a transition from a lowercase letter to an uppercase letter or an asterisk * For example : * * "CreateAccessPointForObjectLambda" would be split into ["Create", "Access", "Point", "For", "Object", "Lambda"] * * "*ObjectTagging*" would be split into ["*", "Object", "Tagging", "*"] * * @param input the IAM Action to split * @returns the parts of the IAM Action */ export declare function splitActionIntoParts(input: string): string[]; /** * Given a list of strings and a list of strings those parts are in, count the number of times each part appears in the strings * * @param substrings the sub strings to count * @param actions the list of strings to count the substrings in * @returns Returns a map of the substring to the number of times it appears in the actions */ export declare function countSubstrings(substrings: string[], actions: string[]): Map; /** * Finds all the the common sequences in a list of actions strings and counts their frequency and length. * * @param actions the list of actions to find common sequences in * @returns an array of objects with the sequence, frequency, and length of the common sequences */ export declare function findCommonSequences(actions: string[]): { sequence: string; frequency: number; length: number; }[]; /** * Consolidates overlapping wildcards into their most general form * * For example: * ['*Object', 'Object*', '*Object*'] will be consolidated into ['*Object*'] * ['Get*', '*Get*'] will be consolidated into ['*Get*'] * * @param patterns the list of patterns to consolidate * @returns the consolidated list of patterns */ export declare function consolidateWildcardPatterns(patterns: string[]): string[]; /** * Check if all access levels are included in the set * * @param accessLevels the set of ActionAccessLevel values to check * @returns true if all access levels are included */ export declare function isAllAccessLevels(accessLevels: Set): boolean; //# sourceMappingURL=shrink.d.ts.map