Skip to content

Conversation

@BLasan
Copy link
Contributor

@BLasan BLasan commented Mar 25, 2024

Purpose

  • Currently, any type of file can be uploaded on a policy creation. Need to restrict the file types to .j2 and .xml
Screenshot 2024-03-25 at 18 14 06

Fixes: wso2/api-manager#2663


const handleDrop = (policyDefinition: any) => {
setPolicyDefinitionFile(policyDefinition);
if(policyDefinition===null || policyDefinition===undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Formatting issues

Copy link
Contributor

Choose a reason for hiding this comment

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

And also this can be simplified as follows.

const handleDrop = (policyDefinition: any) => {
    if (policyDefinition && policyDefinition[0] && (policyDefinition[0].name.endsWith('.j2') || policyDefinition[0].name.endsWith('.xml'))) {
        setPolicyDefinitionFile(policyDefinition);
        return;
    }
    APIMAlert.error(intl.formatMessage({
        id: 'Uploading.Policies.Error',
        defaultMessage: 'Incompatible file type',
    }));
};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@BLasan
Copy link
Contributor Author

BLasan commented Mar 26, 2024

Will add the backend validation as backend does not return an error on adding an incompatible policy file

Tharanidk pushed a commit to Tharanidk/apim-apps that referenced this pull request Mar 27, 2024
Tharanidk pushed a commit to Tharanidk/apim-apps that referenced this pull request Mar 27, 2024
@BLasan BLasan force-pushed the validate-policy-file-type branch from 307516d to 60ef32d Compare April 18, 2024 08:07
@CLAassistant
Copy link

CLAassistant commented Apr 18, 2024

CLA assistant check
All committers have signed the CLA.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
6.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@BLasan BLasan merged commit e09cac4 into wso2:main Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a file type restriction for operation policy definitions

3 participants