CN102279792A - Method for establishing security testing rule base based on extensive makeup language (XML) intermediate model - Google Patents

Method for establishing security testing rule base based on extensive makeup language (XML) intermediate model Download PDF

Info

Publication number
CN102279792A
CN102279792A CN2011102075282A CN201110207528A CN102279792A CN 102279792 A CN102279792 A CN 102279792A CN 2011102075282 A CN2011102075282 A CN 2011102075282A CN 201110207528 A CN201110207528 A CN 201110207528A CN 102279792 A CN102279792 A CN 102279792A
Authority
CN
China
Prior art keywords
rule
xml
node
xquery
defect mode
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN2011102075282A
Other languages
Chinese (zh)
Inventor
周宽久
赖晓晨
王洁
杨广
姚艳双
简道红
崔凯
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Dalian University of Technology
Original Assignee
Dalian University of Technology
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Dalian University of Technology filed Critical Dalian University of Technology
Priority to CN2011102075282A priority Critical patent/CN102279792A/en
Publication of CN102279792A publication Critical patent/CN102279792A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a design of a security testing rule base based on an extensive makeup language (XML) intermediate model, and belongs to the field of software testing. Each rule in the MISRAC++ is abstracted into a defect mode based on the XML intermediate model; the XML intermediate model stores sentence structure information and identifier information of the C++ source code; the defect mode is converted into an XQuery expression by using an XQuery inquiry sentence; aiming at the security breach existed in the C++ language source code, the XML intermediate model corresponding to the C++ source code is inquired; the XML node matching with the defect mode is positioned; and the precise positioning of the defect from the XML intermediate model to the source file is finished through the defect redirecting system. All the XQuery expressions are stored in the system security knowledge base and are maintained separately at the periphery of the system so that the configuration and expansion of the rule can be realized efficiently.

Description

Method for building up based on XML mid-module safety detection rule base
Technical field
The invention belongs to the software testing technology field, relate to method for building up based on the safety detection rule base of XML mid-module.
Background technology
Developing rapidly of infosystem and network makes the security of software become a focus that receives much concern.No matter be in business software or in the open source software, the leak of software is seen everywhere.The leak of software normally produces in the process of software development.C Plus Plus is a kind of powerful, program language with higher execution efficient, but its also is simultaneously a kind of language complexity, type constraint and controling mechanism is loose, coding style program language freely.The software security test is to repair security threat, guarantees the most important means that software can be used safely.At present main safety detecting method has: static code security test and dynamic penetration testing.The static code test is applicable to that early stage code development phase, the present invention are the categories that belongs to the static code test.
The source code analysis technology is of long duration, and along with the continuous evolution of computerese, the technology of source code analysis also is being gradually improved, and a lot of source code analysis instruments occurred.Estimate the static analysis tools quality two indexs are arranged: rate of failing to report and rate of false alarm.How to reduce the rate of failing to report of static analysis tools and rate of false alarm and become the hot issue of software defect in analyzing.The design of healthy and strong rule base is the prerequisite that guarantees Static Detection instrument high efficiency and accuracy.
Summary of the invention
The technical problem to be solved in the present invention is a kind of safety detection rule base based on the XML mid-module of design.The rule of each bar in the safe subclass abstract be defect mode, use the XQuery query statement to convert defect mode to the XQuery expression formula, security breaches at the existence of C Plus Plus source code, the XML mid-module of inquiry C++ source code correspondence, the XML node of location and defect mode coupling is finished the accurate location of defective from the XML mid-module to source file by the defective redirection mechanism.
Technical scheme of the present invention is as follows:
To need in the XML mid-module be to determine the data message that writes down and describe, according to the related C Plus Plus grammar object of rule among the safety subclass MISRA and check the difference of object, rule be divided into following a few class:
Variable declarations/definition class: for the use of the structure that uses in the C Plus Plus, association, enumeration type, class type and typedef, MISRAC++ has all done and has used restriction.Therefore mid-module need write down the statement and the definition information of all variablees.
Programming style class:, prevent to introduce some rules of formulations such as software safety defect because of programmer's error for readability and the ease for maintenance that guarantees program.So mid-module need write down sentence structure information in the source code.
The macro instruction class: C Plus Plus is very flexible to the use of macro instruction, this potential safety hazard under cover flexibly.MISRAC++ has formulated the rule that the aspect was used and write to strict macro instruction, so mid-module needs the text message of record code.
The data manipulation class: the definition of C Plus Plus in data manipulation is also imperfect.MISRA has formulated dependency rule at this potential safety hazard, needs to write down the use information of all variablees in the XML mid-module.
The process class: the using and state and improperly can produce a large amount of potential safety hazards of function in the C Plus Plus, safe subclass MISRAC++ has formulated a large amount of rules and has come the statement of normalized function, definition and use.So need to write down the information of all function declaration, definition and use among the XML.
1, the XML mid-module is formulated
By the analysis of MISRA C++ having been determined the structure of XML mid-module and the data message that should write down: sentence structure information and identifier information, sentence structure model and identifier model in the corresponding XML mid-module of the two difference.Sentence structure information is a unit with the C Plus Plus statement, can embody the concrete implication of each line code in the source file and the context environmental information of being expert at thereof.Each bar statement in the source file is all corresponding CODELINE node in the XML mid-module.Each message unit need comprise statement type, statement content, capable number and optional substatement information.
No matter be basic statement or compound statement, in the XML mid-module, all be mapped as a CODELINE node.The CODELINE node of compound statement comprises 2 attribute nodes and two child nodes, is respectively attribute CODETYPE and LINENUMBER, child node TEXT and SUBLINES, as shown in Figure 2.
Identifier information model description in the XML mid-module information of identifier in the source file.Information such as the name of each identifier equal corresponding identifier in the XML mid-module that defines in the code file, type, assignment record, reference record.The identifier structure of models as shown in Figure 3.
Each part source file to be detected all has its corresponding XML mid-module, the XML mid-module can be regarded as a tree construction, unique root node SOURCEFILE is arranged, and its attribute node FILENAME is in order to the log file name, and FILETYPE is in order to distinguish file type.Corresponding sentence structure model of two child node CODELINES and IDENTIFIERS and identifier information model.
2, the defect mode of MISRA C++ rule
With each bar in the MISRAC++ rule abstract be defect mode.In static analysis tools, defect mode is determining the defect type that system detects, the state of rule and the condition of startup etc.Form by four parts, be respectively the object and the constraint of description entry, status items, use, that is: VP → { DES, STA, OBJ, CON} wherein: VP: defect mode; DES: describe some essential informations of safety rule, generally include two parts: unified numbering and Rule Information, that is: DES → (ID, INFO), ID: the numbering of rule in the safety subclass; INFO: the text description information of rule.STA: the residing state of mark safety rule, value are true or false, and delegate rules is enabled or forbidden.Be STA ∈ { TRUE, FALSE}; Wherein the TRUE representative is enabled, and FALSE represents forbidding.OBJ: the object that safety rule is used.According to the difference of safety rule, object may be a quasi-sentence Statement, as: macro instruction; May be a kind of data type DataType, as: pointer etc.CON: one group of constraint condition of coupling defect mode (P1, P2, P3 ...) and constraint condition between operation relation { AND, OR, NOT}.Form be (condition 1, condition 2 ...) relation.
3, the defect mode expression formula of MISRA C++ rule
XQuery,, utilizes the XQuery language to design its XQuery expression formula for each bar safety rule, and is stored in the security knowledge base on the basis of defect mode the most perfect query language of XML inquiry support as current.Security knowledge base designs based on XML, and as shown in Figure 4, each bar safety rule is a Rule node in security knowledge base, contains four sub-node ID, STATE, ERRORINFO and XQUERY.ID is the key node in the rule, can be unique identify each bar rule in the rule base.STATE is corresponding to the STA in the defect mode.ERRORINFO provides error message corresponding to the INFO in the defect mode to the user.OBJ nuclear CON in the corresponding defect mode of XQUERY according to the relation between the detected object that defines in the defect mode, constraint condition and the constraint condition, makes up the XQuery expression formula.Carry out the XQuery expression formula according to the safety rule in the security knowledge base, return the LINENUMBER attribute of the node of breach of security rule, rule defect is redirected in the source code file.
Beneficial effect of the present invention is to make up the XQuery expression formula and accurately inquire about the node of breach of security rule, thereby be redirected in the source code by C Plus Plus being carried out the middle modeling of XML, reduces rate of failing to report and rate of false alarm, can carry out the configuration of rule flexibly.
Description of drawings
Fig. 1 is the use process flow diagram of safety detection rule base of the present invention.
Fig. 2 is an XML mid-module structural representation.
Fig. 3 is an identifier model structure synoptic diagram.
Fig. 4 is that security knowledge base is based on XML project organization synoptic diagram.
Embodiment
Below in conjunction with technical scheme and accompanying drawing, describe specific embodiments of the invention in detail.
With a rule among the MISRAC++ is the example explanation.
Rule: comma operational symbol, AND operator (﹠amp; ﹠amp; ) and exclusive disjunction symbol (||) can not be by heavy duty.
Aoperator&&(A&a)
{
// certain operations
}
The defect mode of this rule correspondence be VP → DES, STA, OBJ, CON}, wherein the value of each several part is:
DES → (ID, INFO)=(52B0, " comma operational symbol, AND operator (﹠amp; ﹠amp; ) and exclusive disjunction symbol (||) can not be by heavy duty ");
STA=TRUE; This rule is enabled in expression;
OBJ →<Statement:OPERATOR_FUN_DEC|OPERATOR_FUN_DECF 〉; Represent that this safety rule is suitable for to as if the operator overloading function.
Rule request can not heavily loaded comma operational symbol, AND operator and exclusive disjunction symbol, so three constraint conditions are P1: the operational symbol of heavy duty is a comma; P2: the operational symbol of heavy duty is an AND operator; P3: the operational symbol of heavy duty is the exclusive disjunction symbol.Relation between three constraint condition be P1, P2, P3 mutually or.That is:
CON→(P1,P2,P3)OR
In sum, the defect mode of this safety rule correspondence is: VP 52B0→ { (52B0, " comma operational symbol, AND operator (﹠amp; ﹠amp; ) and exclusive disjunction symbol (||) can not be by heavy duty "), TRUE,<Statement:OPERATOR_FUN_DEC | OPERATOR_FUN_DECF 〉, (P1, P2, P3) OR}, P1 wherein, P2, P3 are above-described three constraint conditions.
1. the XQuery expression way of defect mode
XQuery,, utilizes the XQuery language to design its XQuery expression formula for each bar safety rule, and is stored in the security knowledge base on the basis of defect mode the most perfect query language of XML inquiry support as current.Security knowledge base designs based on XML, and each bar safety rule is a Rule node in security knowledge base, contains four sub-node ID, STATE, ERRORINFO and XQUERY.ID is the key node in the rule, can be unique identify each bar rule in the rule base.STATE is corresponding to the STA in the defect mode.ERRORINFO provides error message corresponding to the INFO in the defect mode to the user.OBJ and CON in the corresponding defect mode of XQUERY according to the relation between the detected object that defines in the defect mode, constraint condition and the constraint condition, make up the XQuery expression formula.Carry out the XQuery expression formula according to the safety rule in the security knowledge base, return the LINENUMBER attribute of the node of breach of security rule, software defect is redirected in the source code file.
According to last joint to Rule comma operational symbol, AND operator (﹠amp; ﹠amp; ) and exclusive disjunction symbol (||) can not be by the analysis of heavily loaded defect mode, this regular XQuery implementation algorithm is as follows:
Testing result is analyzed, and this rule is failed to report and wrong report is 0, and success ratio is 100%.
Illustrate the design proposal of rule below respectively at the classification of rule of the present invention:
Variable declarations/definition class: the identifier in the internal layer statement should will not hidden at the identifier of skin statement.
Define outward with piece in the piece: having in full, the identifier of part action scope is called the outermost layer identifier; Has interior layer identifier of being called of piece action scope; Order, nested piece introduces more internal layer territory.
This rule relates to the statement of two ID, suitable to as if the statement of two identifiers, the relation of two objects is internal layer and outer field relation, constraint condition is that the name of two identifiers is identical, this regular XQuery implementation algorithm is as follows:
Figure BDA0000078087430000082
By getting rid of the statement of statement block and friend function, reduced should rule rate of false alarm.
The programming style class: all if...else... structures all should finish with an else subordinate sentence.
This application of rules to as if the if statement, constraint condition is that first subsequent node is not else or does not have subsequent node.This regular XQuery implementation algorithm is as follows:
Figure BDA0000078087430000091
The macro instruction class: (pressure) is grand can only to be defined (#define) or cancellation (#undef) in global namespace.
The object of this application of rules is the statement in the non-global namespace, and constraint condition is PREDEFINE or PREUNDEF.This regular XQuery implementation algorithm is as follows:
Figure BDA0000078087430000092
Data manipulation class: forbid surpassing two-level pointer.
The object of this application of rules is the pointer type, and constraint condition is that pointer surpasses two-stage.This regular XQuery implementation algorithm is as follows:
Figure BDA0000078087430000093
Figure BDA0000078087430000101
The process class: parameter identifier should be consistent with former statement when heavily stating.
Two of this application of rules to as if the statement of function and the definition of function, constraint condition is to exist the identifier of parameter inequality.This regular XQuery implementation algorithm is as follows:
Figure BDA0000078087430000102
This rule has used three self-defining functions to be respectively:
Local:findOwner ($currentNode as item () , $strOwner as xs:string) as item (), the node that finds corresponding OWNER by character string and the current node of handling of OWNER;
Local:funcEqual ($funcID1 as item () , $funcID2 as item ()) as xs:boolean judges that it is that one of definition is statement that two functions are one;
Local:isSame ($parac as item () , $paraf as item ()) as xs:boolean judges whether the parameter identifier of two functions (dec and def) is identical.

Claims (1)

1. the method for building up based on XML mid-module safety detection rule base is characterized in that following steps, and (1) XML mid-module is formulated
No matter be basic statement or compound statement, in the XML mid-module, all be mapped as a CODELINE node; The CODELINE node of compound statement comprises 2 attribute nodes and two child nodes, is respectively attribute CODETYPE and LINENUMBER, child node TEXT and SUBLINES;
Each part source file to be detected all has its corresponding XML mid-module, regards the XML mid-module as a tree construction, and unique root node SOURCEFILE is arranged, and its attribute node FILENAME is in order to the log file name, and FILETYPE is in order to distinguish file type; Corresponding sentence structure model of two child node CODELINES and IDENTIFIERS and identifier information model;
(2) defect mode of MISRAC++ rule
With each bar in the MISRA C++ rule abstract be defect mode; Form by four parts, be respectively the object and the constraint of description entry, status items, use, that is: VP → { DES, STA, OBJ, CON} wherein: VP: defect mode; DES: describe some essential informations of safety rule, comprise two parts: unified numbering and Rule Information, that is: DES → (ID, INFO), ID: the numbering of rule in the safety subclass; INFO: the text description information of rule; STA: the residing state of mark safety rule, value are true or false, and delegate rules is enabled or forbidden; Be STA ∈ { TRUE, FALSE}; Wherein the TRUE representative is enabled, and FALSE represents forbidding; OBJ: the object that safety rule is used; According to the difference of safety rule, to liking a quasi-sentence Statement or a kind of data type DataType; CON: one group of constraint condition of coupling defect mode (P1, P2, P3 ...) and constraint condition between operation relation { AND, OR, NOT}; Form be (condition 1, condition 2 ...) relation;
(3) the defect mode expression formula of MISRAC++ rule
XQuery,, utilizes the XQuery language to design its XQuery expression formula for each bar safety rule, and is stored in the security knowledge base on the basis of defect mode the most perfect query language of XML inquiry support as current; Security knowledge base designs based on XML, and is as shown in the table, and each bar safety rule is a Rule node in security knowledge base, contains four sub-node ID, STATE, ERRORINFO and XQUERY; ID is the key node in the rule, can be unique identify each bar rule in the rule base; STATE is corresponding to the STA in the defect mode; ERRORINFO provides error message corresponding to the INFO in the defect mode to the user; OBJ nuclear CON in the corresponding defect mode of XQUERY according to the relation between the detected object that defines in the defect mode, constraint condition and the constraint condition, makes up the XQuery expression formula; Carry out the XQuery expression formula according to the safety rule in the security knowledge base, return the LINENUMBER attribute of the node of breach of security rule, rule defect is redirected in the source code file.
CN2011102075282A 2011-07-25 2011-07-25 Method for establishing security testing rule base based on extensive makeup language (XML) intermediate model Pending CN102279792A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2011102075282A CN102279792A (en) 2011-07-25 2011-07-25 Method for establishing security testing rule base based on extensive makeup language (XML) intermediate model

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2011102075282A CN102279792A (en) 2011-07-25 2011-07-25 Method for establishing security testing rule base based on extensive makeup language (XML) intermediate model

Publications (1)

Publication Number Publication Date
CN102279792A true CN102279792A (en) 2011-12-14

Family

ID=45105252

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2011102075282A Pending CN102279792A (en) 2011-07-25 2011-07-25 Method for establishing security testing rule base based on extensive makeup language (XML) intermediate model

Country Status (1)

Country Link
CN (1) CN102279792A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102866952A (en) * 2012-10-11 2013-01-09 山东省科学院自动化研究所 Automobile software source code simulation test method based on UPPAAL model
CN106997320A (en) * 2016-01-22 2017-08-01 阿里巴巴集团控股有限公司 Code display methods and device during code review
CN109857641A (en) * 2018-12-29 2019-06-07 北京奇安信科技有限公司 The method and device of defects detection is carried out to program source file
CN113821210A (en) * 2021-09-17 2021-12-21 中汽创智科技有限公司 File analysis method and device and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070050427A1 (en) * 2005-08-02 2007-03-01 Steven Atkin System and method for validating application globalization issues and computer product
CN101017458A (en) * 2007-03-02 2007-08-15 北京邮电大学 Software safety code analyzer based on static analysis of source code and testing method therefor

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070050427A1 (en) * 2005-08-02 2007-03-01 Steven Atkin System and method for validating application globalization issues and computer product
CN101017458A (en) * 2007-03-02 2007-08-15 北京邮电大学 Software safety code analyzer based on static analysis of source code and testing method therefor

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
周宽久 等: "基于XML的软件安全静态检测方法研究", 《计算机工程与应用》, vol. 46, no. 28, 1 October 2010 (2010-10-01), pages 64 - 69 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102866952A (en) * 2012-10-11 2013-01-09 山东省科学院自动化研究所 Automobile software source code simulation test method based on UPPAAL model
CN102866952B (en) * 2012-10-11 2014-12-10 山东省科学院自动化研究所 Automobile software source code simulation test method based on UPPAAL model
CN106997320A (en) * 2016-01-22 2017-08-01 阿里巴巴集团控股有限公司 Code display methods and device during code review
CN109857641A (en) * 2018-12-29 2019-06-07 北京奇安信科技有限公司 The method and device of defects detection is carried out to program source file
CN109857641B (en) * 2018-12-29 2022-09-13 奇安信科技集团股份有限公司 Method and device for detecting defects of program source file
CN113821210A (en) * 2021-09-17 2021-12-21 中汽创智科技有限公司 File analysis method and device and storage medium

Similar Documents

Publication Publication Date Title
JP5791698B2 (en) Code inspection execution system for ABAP source code
Rose et al. The epsilon generation language
Küster et al. Detecting and resolving process model differences in the absence of a change log
Hou et al. Using SCL to specify and check design intent in source code
Castelo Branco et al. Matching business process workflows across abstraction levels
Kapdan et al. On the structural code clone detection problem: a survey and software metric based approach
EP2141587A1 (en) Method and system for generating of a control flow graph for representing a program code
Guana et al. Chaintracker, a model-transformation trace analysis tool for code-generation environments
CN102279792A (en) Method for establishing security testing rule base based on extensive makeup language (XML) intermediate model
Karagiannis et al. Metamodels as a conceptual structure: some semantical and syntactical operations
CN102298552A (en) Method for performing source code instrumentation on the basis of code inquiry
Singh et al. Literature analysis on model based slicing
Samuel et al. A novel test case design technique using dynamic slicing of UML sequence diagrams
Diab et al. Formalizing cosmic-ffp using room
Priya et al. Test Case Generation from UML models-A survey
Jamal et al. Formalizing structural semantics of UML 2.5 activity diagram in Z Notation
Bougouffa et al. Scalable cloud based semantic code analysis to support continuous integration of industrial PLC code
Rodrigues et al. Towards a structured specification of coding conventions
Du Bois et al. Supporting reengineering scenarios with FETCH: an experience report
Simeckova et al. SPEM-Based Process Anti-Pattern Models for Detection in Project Data
Qaisar et al. A safe regression testing approach for safety critical systems
Cherinka et al. Maintaining a COTS integrated solution-are traditional static analysis techniques sufficient for this new programming methodology?
Schneid et al. Data-Flow analysis of BPMN-based process-driven applications: detecting anomalies across model and code
Abbas et al. Formalizing and verifying UML activity diagrams
Febbraro et al. Datalog development tools

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C02 Deemed withdrawal of patent application after publication (patent law 2001)
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20111214