-2
public with sharing class VehicleController {
    @AuraEnabled(Cacheable=true)
    public static List<Vehicle__c> getVehicleList() {
        return [SELECT Id, Veichle_Name__c, Rental_Rate__c, Make__c, Registration_Number__c, Vehicle_Image__c, Emission__c 
                FROM Vehicle__c];
    }
}

1 Answer 1

1

This rule violation states that appropriate permissions are not checked before DML / SOQL.

After Spring'20 release , we can easily apply CRUD & Object permissions using the WITH SECURITY_ENFORCED in SOQL as below :

    public with sharing class VehicleController {
      @AuraEnabled(Cacheable = true) 
      public static List < Vehicle__c > getVehicleList() {
          List<Vehicle_c> vehiclesList;
           try {
               vehiclesList = [SELECT Id, Veichle_Name__c, Rental_Rate__c, Make__c, Registration_Number__c, Vehicle_Image__c, Emission__c FROM Vehicle__c WITH SECURITY_ENFORCED];
           } catch(System.QueryException ex) {
                System.debug(ex.getMessage());
            }
        return vehiclesList;
      }
    
    }

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .