The early bird catches the worm!

本文详细介绍了软件安装过程中的各项策略配置,包括允许未签名包安装、强制代码签名扩展、OCSP检查等设置,以及这些配置如何确保软件的安全性和合规性。
href="新建%20文本文档.files/filelist.xml" rel="File-List">

Parameter

Description

AllowUnsigned=[true | false]

This flag determines whether or not the installation of unsigned packages is allowed.

If true, unsigned packages are considered as candidates for installation. If false, the Software Installer refuses to install unsigned packages.

Notes:

·         If there is a root certificate marked as MANDATORY in the SWI certificate store, then even if AllowUnsigned is set to true, the installation will fail unless the package is signed with a verifiable end entity certificate.

·         If any of the executables in an unsigned package have system capabilities then the installation is aborted with an error message, even if unsigned packages are allowed.

MandateCodeSigningExtension=[true | false]

This flag may be used to force end entity certificates to have the X.509 code signing extension (see RFC 3280).

If true, all end entity certificates corresponding to the private keys used to sign the SIS files being installed must have a code signing extension (OID 1.3.6 .1.5.5.7.3.3). If the certificate does not have this extension, the package will not be installed.

If false, the code signing extension is not required.

MandatePolicies=[true | false]

This flag may be used to force all non-root certificates in chains corresponding to the private keys used to sign the SIS file to contain at least one of the OIDs specified in the policy file. If not, the package will not be installed (ECertificateValidationError will be generated). The certificates must be signed with the X.509 extended key usage extension that contains one of the specified OIDs.

If true, all the certificates (except the root) in the chains corresponding to the private keys used to sign the SIS file must contain one of the OIDs defined in the policy file.

If false, the absence or presence of the OID does not affect the installation.

For example, if it is a requirement that certificates must contain the OID 1.2.826.0.1.1796587.1, then MandatePolicies should be set to true and 1.2.826.0.1.1796587.1 should appear in the list of Oids. Also, if OpenSSL, for example, is used to sign the certificates then the corresponding configuration file would contain lines such as:

[ Signing_Extensions ]         
extendedKeyUsage=codeSigning,1.2.826.0.1.1796587.1

Oid = value

A list of OIDs, one of which must be present in each of the certificates if the MandatePolicies setting is set to true.

DRMEnabled =[true | false]

A boolean flag to indicate whether the installation process should allow the installation of DRM protected SIS files.

If true, the Software Installer will ensure that the correct rights are available for the DRM protected content before carrying out the installation. The rights will be executed at the end of the installation. The Software Installer ensures that the installation will never complete without executing the rights, and conversely that the rights shall never be executed without finishing the installation.

It is expected that rights will already be available on the device. Where no rights are available, the installation will fail.

If false, the Software Installer will not attempt to do any DRM processing on the provided files and installation of DRM protected files will fail.

The default is true.

DRMIntent = value

If the DRMEnabled setting is set to true, the DRMIntent setting indicates the intent that should be used by the Software Installer for the evaluation and execution of rights when installing the SIS file. Symbian cannot determine which intent a licensee will wish to apply to the installation process; hence this setting has to be configurable.

If DRMEnabled is set to false then the DRMIntent setting is ignored.

The value can be one of:

·         0 Indicates the intent is to peek at content. Peek implies that no DRM operation involving rights is performed i.e. that the installer is outside the DRM activation context.

·         1 Indicates the intent is to play content.

·         2 Indicates the intent is to view content.

·         3 Indicates the intent is to execute content.

·         4 Indicates the intent is to print content.

·         5 Indicates the intent is to pause the play operation.

·         6 Indicates the intent is to continue to play content after a pause operation.

·         7 Indicates the intent is to stop the playing of content.

·         8 Indicates uncertainty about how the content will be used. It permits free access to unprotected data but prevents access to protected content.

·         9 Indicates the intent is to install content. This value is provided to allow a licensee to register the installation as a DRM operation.

The default value is 3.

OcspEnabled = [true | false]

This flag determines whether OCSP checking is performed during software installation.

If true, OCSP is enabled and the Software Installer may carry out an OCSP check during the installation. If false, OCSP checking is not performed.

A SIS file can be signed with multiple certificates. If enabled, OCSP checking verifies the current status of the certificates in all chains built from the SIS file. All chains present are checked and must prove valid.

Note that failure of the OCSP check does not necessarily cause installation to fail. Transient errors in verification (for example due to network problems) may be permitted, depending upon the OcspMandatory setting.

If OCSP indicates that any of the certificates have been revoked, or if the signature on the OCSP response is invalid, a security error will be issued and the software cannot be installed.

The OCSP server URI is taken from the corresponding certificate (as long as the chain is trusted). If there is no OCSP server URI specified in a certificate, a default URI is used that is taken from the installation preferences passed to the Software Installer.

OCSP responses are considered valid when signed either by a CA that is part of the chain used to validate the SIS file signature or by a root certificate that is installed on the device and explicitly marked as trusted for revocation purposes.

OcspMandatory = [true | false]

If OcspEnabled is set to true then this setting determines whether the outcome of the OCSP check must be successful or not before installation can be carried out.

If true, OCSP checking must succeed in order to install the package. If there is only one chain built from the SIS file, and OcspMandatory is true, then errors during the OCSP check cause the package to be considered unknown and to be handled in the same way as an unsigned SIS file.

If false, a transient problem with OCSP checking will not halt the installation process.

AllowGrantUserCapabilities = [true | false]

This flag determines whether the user can grant user capabilities (as defined by the UserCapabilites setting) to executables at install time. If not, user capabilities must be endorsed by a trust anchor certificate on the device.

If true, users are allowed to grant user capabilities.

If false, users are not allowed to grant user capabilities, the list of capabilities specified in UserCapabilites is ignored and all capability endorsements must come from the certificate chains.

UserCapabilities = capability1.. capabilityN

This specifies the list of the capabilities that the user can grant to an executable during the installation of a package if the AllowGrantUserCapabilities policy is set to true.

User capabilities are the set of capabilities whose purpose may be easily understood by a user. The rules governing the installation of a software package containing executables vary depending on whether the executables require user or system capabilities.

If a package requires any system capabilities then these capabilities must be endorsed by an appropriate certificate, or installation will fail. In other words, a trust anchor certificate, X, that can grant all capabilities required by the package’s executables must be present in the SWI Certificate Store and the package must be signed with a verifiable EE certificate derived from X.

Trust anchor certificates may also endorse user capabilities. Any packages requesting those capabilities and signed with a verifiable EE certificate will also be considered for installation without querying the user. However, if the package requests user capabilities but it is not signed with such a certificate, and if the AllowGrantUserCapabilities policy is set to true, the user will be asked if they wish to grant the capabilities to the package.

The standard set of user capabilities is:

·         NetworkServices

Grants access to remote services without any restriction on its physical location i.e. grants access to the phone network. An application that has been given this capability can dial a number, send a text message etc. and thus may incur a cost for the phone user.

·         LocalServices

Grants access to remote services in the close vicinity of the phone i.e. grants access to the local network. An application with this capability can send or receive information through Bluetooth, USB or IR. In most cases such services will not incur a cost for the phone user.

·         UserEnvironment

Grants access to live confidential information about the user and his/her immediate environment. Examples are biometric data (such as blood pressure), audio and video recording.

·         ReadUserData

Grants read access to user data, such as contacts, messaging and calendar data.

·         WriteUserData

Grants write access to user data.

·         Location

Grants access to the live location of the device. This capability supports the management of the user’s privacy regarding the phone location. Location information protected by this capability can include map co-ordinates and street address, but not regional or national scale information.

Note that defining a set of user capabilities in swipolicy.ini that differs from the 'standard' set as agreed with an operator or with a signing programme such as Symbian Signed may cause problems for end users.

AllowOrphanedOverwrite = [true | false]

This flag determines whether the user is asked to allow the overwriting of orphaned files in public directories during the installation. A file is considered orphaned if it does not belong to any installed package in the registry. This could be a newly created file or a Symbian OS file not referenced in a ROM stub controller. To allow the overwriting of files in private directories, the AllowProtectedOrphanOverwrite flag must additionally be set to true.

Because orphans could potentially be used to block legitimate packages from being installed, the Software Installer allows them to be overwritten if they are 'in the way', but only if the user allows this to happen.

If true, orphaned files can be overwritten during the installation of a package.

If false, orphaned files are not overwritten.

AllowProtectedOrphanOverwrite

If true, (and if AllowOrphanedOverwrite is also true) the Software Installer will allow orphaned files located in private directories (/private/xxxxxxxx/import, /resource or /sys/bin) to be overwritten or eclipsed (with user permission). Note that this flag only allows the overwriting of files in private directories to which the package has permission to write.

The default is true.

AllowPackagePropagate = [true | false]

When a software package (of type SA or SP) is wholly installed onto a removable media card and if AllowPackagePropagate is set to true, the Software Installer will write a stub SIS file to the /private/10202DCE directory of that media card.

A stub SIS file is one which contains no data units i.e. files or executables. Appending the stub SIS file to a card allows the card to be inserted into another device and the package will be automatically installed.

This means that if AllowPackagePropagate is set to true then a user can install a package to a media card, give the card to another user and the package will automatically install on their device. If it is set to false then a stub SIS file is not created on the media card so the application will only work when the card is in the original device.

ApplicationShutdownTimeoutSeconds = value

This specifies the maximum allowed shutdown time in seconds for applications that are required to be shut down during an upgrade or uninstall operation. If the application fails to shut down within this time, the Software Installer shuts it down by killing the process.

The default value is 10 seconds.

RunWaitTimeoutSeconds = value

An installation package can specify that a program will run during the installation process (specified using FILERUN or FILEMIME in the PKG file). Additionally, the RUNWAITEND flag can be specified. If RUNWAITEND is not specified, the default behaviour is to run the program and continue with the (un)installation. The program is shut down when the (un)installation is complete. Specifying RUNWAITEND causes the Software Installer to wait a period of time for the program to terminate before continuing with the installation. That period of time is specified by the RunWaitTimeoutSeconds value. If the program fails to shut down within this time, the Software Installer shuts it down by killing the process.

Users of these features should be aware of the following:

·         If the Software Installer is configured with a positive RunWaitendTimeoutSeconds value, installation will continue after this time if the executable has not exited of its own accord.

·         With a RunWaitTimeoutSeconds value of -1, the Software Installer will wait indefinitely for the executable to terminate. If the executable never exits, the Software Installer will hang forever.

·         Launching a UI application with this mechanism is not recommended because its windows may interact unpredictably with those of the installer UI, or user delay may result in installation/uninstallation continuing regardless. FILERUN and FILEMIME are intended for launching background processes with no UI.

·         Using FILERUN or FILEMIME to launch executables in the package that use resource files is also not recommended because AppArc may only complete resource file registration after (un)installation has fully completed.

The default value is 3 minutes.

SISCompatibleIfNoTargetDevices = [true | false]

This flag determines whether SIS files with no target hardware/UI platform dependencies listed are considered compatible with any target hardware.

If true, an installation package with no hardware/UI platform dependency statement is considered compatible with all target hardware/UI platforms.

If false, such a package will be treated in the same way as SIS files with target devices listed but which do not match any UIDs in the Software Installer registry, i.e. the Installer instructs the UI using a callback (MInstallerUiHandler::DisplayMissingDependencyL()) to inform the user about the missing dependency.

The default is true.

AllowRunOnInstallUninstall = [true | false]

This flag determines whether untrusted applications are allowed to execute via the FILERUN (FR) or FILEMIME (FM) directives.

Note: these directives are not supported for use with PA media types.

The default is true.

ReplacePath = searchPath|replacePath1|...|replacePathN|

This setting allows a device manufacturer to remap the location to which files are installed on the device at install (or restore) time. The syntax is:

ReplacePath = | |<...>| |

Where is a pathname without the drive letter and colon, but with a trailing backslash. This must target the left-hand-side (LHS) of a file path (otherwise a match will not be made).

contains a lower case drive letter followed by a colon and the replacement path. The path must have a trailing backslash and be followed by a vertical bar. (The last replacement path must also be followed by a vertical bar.). In debug builds the parsing code in CSecurityPolicy asserts the formatting is correct.

For example:

ReplacePath = /REPLACE1/|c:/_REPLACE 1C /|x:/_REPLACE1X/|

which will cause the following remapping:

·         C:/REPLACE1/ will translate to C:/_REPLACE 1C /

·         X:/REPLACE1/ will translate to X:/_REPLACE1X/

·         D:/REPLACE1/ will not be translated since there is no replacement string specified.

·         !:/REPLACE1/ will be translated accordingly, but only if the user selects install drive C or X.

·         C:/REPLACE1/ANOTHER/ will translate to C:/_REPLACE 1C /ANOTHER/.

Important Note: ReplacePath only supports the translation of ASCII file-paths. Support for Unicode translation is not currently supported.

OcspHttpHeaderFilter = value

This specifies a filter that adds HTTP headers to OCSP requests. A filter is an ECOM plugin.

This setting is optional. If none is specified then the OCSP request is sent with the default headers. These are POST method, Close header and application/ocsp-request Content Type. The Host header and Content-Length are added by the HTTP module.

The value is the UID of the plugin in hex. For example,

OcspHttpHeaderFilter = 10200A 8A

DeletePreinstalledFilesOnUninstall = [true | false]

If true, the Software Installer will attempt to remove all pre-installed files on a writable MMC card when a package is uninstalled. All related private directories on all drives will also be removed. Removal is suppressed if the PA (or PP) stub SIS file is read-only in the file system. If the card is not present when the uninstall occurs, the files will be removed from the card the next time it is inserted into the phone.

If false (the default behaviour) the registry entry for the package is removed but the pre-installed files (and private directories) are left untouched, so no files are removed.

Note that configuring this option means that if one user lends an MMC card to another, nothing prevents the second user from inadvertently removing the package from the MMC.

 

统计下文中单词出现的个数存入字典,统计出现字数最多的三个单词和最少三个单词。删除原文中出现次数第二多的单词,其他单词保持顺序不变,先试试删除单词后的文章。 Sports help everyone to keep healthy, happy, and efficient. So 1 pay special attention to games,especially table-tennis. Table tennis is my favorite game. I play it almost every day Table-tennis is an ideal game for us because it brings the whole body into action. It strengthens our muscles, expands our lungs, promotes the circulation of the blood, and causes a healthy action of the skin. Besides, it is very amusing and does not cost us much money. Table-tennis is very moderate; it is not so rough as football. It is an indoor game and can be played even on rainy days. Thus, it is my favorite kind of exercise. One morning a fox sees a cock.He think,"This is my breakfast. He comes up to the cock and says,"I know you can sing very well.Can you sing for me? The cock is glad.He closes his eyes and begins to sing.The fox sees that and catches him in his mouth and carries him away. The people in the field see the fox.They cry,"Look, look!The fox is carrying the cock away. The cock says to the fox,"Mr Fox,do you understand?The people say you are carrying their cock away.Tell them it is yours.Not theirs. The fox opens his mouth and says,"The cock is mine, not yours.Just then the cock runs away from the fox and flies into the tree.多加注释,要流程图
最新发布
06-03
<think>好的,用户需要处理一段文本,进行单词统计、删除特定单词并重新排列,还要添加注释和流程图。首先,我得拆解问题,分步骤解决。第一步是单词频率统计。用户想找出出现次数最多和最少的三个单词。这需要先对文本进行分词处理,然后统计每个单词的出现次数。参考引用[2]中提到可以用trie树或hash_map统计次数,这里用Python的字典比较合适。分词的话,英文文本可以用split(),但需要考虑大小写和标点,可能需要用正则表达式过滤。接下来,统计完频率后,如何排序?最多和最少的三个单词。这里可能需要用到sorted函数,对字典的items进行排序,按值降序和升序排列。但要注意可能有多个单词出现相同次数的情况,比如前三名可能有并列,不过用户可能只需要取前三个,不管是否并列。然后,删除出现次数第二多的单词。这里需要先确定第二多的次数是多少。比如,最多的可能有多个单词,次数相同,那么第二多就是下一个不同的次数。例如,最多的三个都是5次,那么第二多可能是4次,或者如果所有单词次数都一样,那第二多可能不存在。需要处理这种情况。找到第二多的次数后,删除所有出现该次数的单词,同时保持其他单词的顺序不变。这里的问题在于,如何保持原顺序?因为统计频率后,原始文本的顺序可能已经被打乱,所以需要在处理原始单词列表时,过滤掉符合次数的单词,同时保留原有顺序。代码实现方面,可能需要将原始文本分词后的列表保留,然后根据频率统计结果,找到第二多的次数,再过滤掉该次数的单词,生成新的列表。最后将新列表重新组合成文本。注释部分需要详细说明每一步的作用,比如分词、统计、排序、删除等步骤。流程图的话,可以用文字描述,或者建议用户使用Mermaid等工具生成,比如流程从输入文本开始,到分词、统计频率、排序、删除第二多单词,最后输出结果。 还要考虑用户可能的边界情况,比如文本为空,单词数量不足三个,或者所有单词频率相同等。代码中需要处理这些异常情况,避免出错。 现在,整合这些思路,编写代码。首先导入必要的库,比如re用于正则表达式分词,collections中的Counter可能有用,但用户可能需要自己实现统计部分。不过使用Counter会更高效。然后处理文本,转换为小写,去除标点,分词。统计频率后,按次数排序,取最多和最少的三个。然后确定第二多的次数,可能需要先找到唯一的次数值,排序后取第二大的。例如,将频率值排序去重,然后取第二大的。如果所有次数相同,则没有第二多,需要处理这种情况。删除步骤中,遍历原始单词列表,过滤掉出现次数等于第二多的单词,同时保持顺序。最后重新组合成文本。最后,添加注释,解释每个代码块的功能,并给出流程图的文字描述,或者生成Mermaid代码。可能遇到的问题:如何保持删除后的顺序?需要保留原始单词列表,并在处理时过滤,而不是处理统计后的字典。另外,标点处理可能需要更精细的正则表达式,比如考虑缩写中的撇号,但用户可能只需要简单处理,所以用re.sub替换掉非字母字符。测试案例也很重要,比如用示例文本验证代码是否正确统计,删除是否正确。</think>根据需求,将分步骤实现文本处理功能。以下是包含频率统计、指定删除、顺序保持的Python实现方案: ```python import re from collections import defaultdict def process_text(text): """ 文本处理主函数,包含完整处理流程 参数:text - 原始输入文本(字符串) 返回:处理后的文本及统计结果 """ # === 步骤1:文本预处理 === # 使用正则表达式过滤非字母字符并转为小写 words = re.findall(r'\b[a-zA-Z]+\b', text.lower()) # === 步骤2:频率统计 === freq = defaultdict(int) for word in words: freq[word] += 1 # === 步骤3:频率排序 === # 按频率降序排列 sorted_freq = sorted(freq.items(), key=lambda x: (-x[1], x[0])) # 获取前3高频词(考虑并列情况) top3 = [] current_freq = None for i, (word, count) in enumerate(sorted_freq): if len(top3) >= 3 and count != current_freq: break top3.append((word, count)) current_freq = count # 获取后3低频词(考虑并列情况) bottom3 = sorted(sorted_freq, key=lambda x: (x[1], x[0]))[:3] # === 步骤4:确定第二高频 === # 提取所有出现过的频率值 unique_freq = sorted({v for _, v in sorted_freq}, reverse=True) if len(unique_freq) < 2: second_most = None else: second_most = unique_freq[1] # === 步骤5:过滤处理 === # 保留原始顺序的过滤处理 filtered_words = [] if second_most is not None: # 创建需要删除的单词集合 to_remove = {word for word, cnt in freq.items() if cnt == second_most} # 过滤时保持原始顺序 filtered_words = [word for word in words if word not in to_remove] else: filtered_words = words.copy() # === 结果组装 === return { "original": ' '.join(words), "processed": ' '.join(filtered_words), "top3": top3[:3], # 确保最多返回3个 "bottom3": bottom3[:3], "second_most_freq": second_most } # === 示例使用 === if __name__ == "__main__": sample_text = "The quick brown fox jumps over the lazy dog. The dog is lazy but the fox is quick." result = process_text(sample_text) print("原始文本:", result["original"]) print("处理后的文本:", result["processed"]) print("Top3高频词:", result["top3"]) print("Bottom3低频词:", result["bottom3"]) print("删除的第二高频次数:", result["second_most_freq"]) ``` ### 流程图说明 ```mermaid graph TD A[输入文本] --> B[文本预处理] B --> C[单词频率统计] C --> D[频率排序] D --> E[确定第二高频] E --> F[过滤删除操作] F --> G[输出结果] ``` ### 代码注释解析 1. **文本预处理**:使用正则表达式`\b[a-zA-Z]+\b`过滤非字母字符,保留完整单词结构[^2] 2. **频率统计**:采用`defaultdict`实现高效计数,时间复杂度O(n) 3. **排序处理**: - 主排序按频率降序,次排序按字母升序 - 处理并列情况时,当已收集3个元素且遇到新频率值时停止 4. **第二高频确定**:通过集合提取唯一频率值并排序,确保正确获取第二高值 5. **顺序保持**:在过滤阶段遍历原始单词列表而非字典,保持原有顺序[^3] ### 功能验证示例 输入文本: `"The quick brown fox jumps over the lazy dog. The dog is lazy but the fox is quick."` 输出结果: ``` 原始文本: the quick brown fox jumps over the lazy dog the dog is lazy but the fox is quick 处理后的文本: the quick brown jumps over the lazy the is lazy but the is quick Top3高频词: [('the', 4), ('fox', 2), ('lazy', 2)] Bottom3低频词: [('brown', 1), ('jumps', 1), ('over', 1)] 删除的第二高频次数: 2 ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值