1# File Subsystem Changelog 2 3## cl.CoreFileKit.1 setSecurityLabel() Behavior Change 4 5**Access Level** 6 7Public API 8 9**Reason for Change** 10 11The **setSecurityLabel()** method does not verify the security label passed in. Changing the security label from a higher level to a lower one poses security risks. 12 13**Change Impact** 14 15This change is a non-compatible change. 16 17Before the change: 18 19The application data security label can be changed to a lower level by using the following API after being set. 20 21After the change: 22 23If the application data security label is set to a lower lever, error 13900020 will be thrown. 24 25```ts 26import {fileIo,securityLabel} from '@kit.CoreFileKit'; 27try { 28 let path = getContext().filesDir + '/text.txt'; 29 let file = fileIo.openSync(path,fileIo.OpenMode.CREATE); 30 securityLabel.setSecurityLabelSync(file.path, "s4"); 31 securityLabel.setSecurityLabelSync(file.path, "s3"); 32 console.log( "set security label s3 success"); 33} catch (err) { 34 console.log( "set security label s3 fail, " + err.message + err.code); 35} 36``` 37 38**Start API Level** 39 40API 9 41 42**Change Since** 43 44OpenHarmony SDK 5.0.0.38 45 46**Key API/Component Changes** 47 48| API| Before the Change| After the Change| 49| ------------------------------------------------------------ | --------- | ------ | 50| setSecurityLabel(path:string, type:DataLevel):Promise<void> | The data security label can be changed from a higher level to a lower one.| An error will be thrown if the data security label is changed from a higher level to a lower one.| 51| setSecurityLabel(path:string, type:DataLevel, callback: AsyncCallback<void>):void | The data security label can be changed from a higher level to a lower one.| An error will be thrown if the data security label is changed from a higher level to a lower one.| 52| setSecurityLabelSync(path:string, type:DataLevel):void | The data security label can be changed from a higher level to a lower one.| An error will be thrown if the data security label is changed from a higher level to a lower one.| 53 54**Adaptation Guide** 55 56If your application does not need to set the data security label frequently, no adaptation is required. Otherwise, ensure that the data security label settings comply with security specifications. An error will be thrown if the API is used to set the security label from a higher level to a lower one. 57 58## cl.CoreFileKit.2 getSecurityLabel() Behavior Change 59 60**Access Level** 61 62Public API 63 64**Reason for Change** 65 66If no security label has been set for application data, calling **getSecurityLabel** returns an empty string, which does not comply with the security design. After the change, **s3** is returned. 67 68**Change Impact** 69 70This change is a non-compatible change. 71 72Before the change: 73 74If **getSecurityLabel()** is called for the data without any security label, an empty string is returned by default. After the following code is executed, **label** in the log is an empty string. 75 76After the change: 77 78If **getSecurityLabel()** is called for the data without any security label, **s3** will be returned by default. After the following code is executed, **label** in the log is **s3**. 79 80```ts 81import {fileIo,securityLabel} from '@kit.CoreFileKit'; 82try { 83 let path = getContext().filesDir + '/text.txt'; 84 let file = fileIo.openSync(path,fileIo.OpenMode.CREATE); 85 let label = securityLabel.getSecurityLabelSync(file.path); 86 console.log( "get security label success, label is" + label); 87} catch (err) { 88 console.log( "get security label fail, " + err.message + err.code); 89} 90``` 91 92**Start API Level** 93 94API 9 95 96**Change Since** 97 98OpenHarmony SDK 5.0.0.38 99 100**Key API/Component Changes** 101 102| API| Before the Change| After the Change| 103| ------------------------------------------------------------ | --------- | ------ | 104| getSecurityLabel(path:string, callback:AsyncCallback<string>): void | By default, an empty string is returned.| **s3** is returned by default.| 105| getSecurityLabel(path:string):Promise<string> | By default, an empty string is returned.| **s3** is returned by default.| 106| getSecurityLabelSync(path:string):string | By default, an empty string is returned.| **s3** is returned by default.| 107 108**Adaptation Guide** 109 110This change is a bugfix and no adaptation is required for the application. When **getSecurityLabel()** is used to obtain the data security label, **s3** is returned if no security label has been set. 111