yaad96/DesignFix-client

GitHub: yaad96/DesignFix-client

DesignFix 是一个基于 React 的设计规则执行工具客户端,通过结构化源码解析和 XPath 查询实现设计规则的编写、违规检测与修复建议。

Stars: 0 | Forks: 0

# DesignFix 此应用使用 "React" 框架编写。 - 它通过 "Web-Socket" 与 [IDE Connector](https://github.com/yaad96/DesignFix--Extension) 进行通信。 - 它基于 _srcML_ 库,您应该按照[此处](https://github.com/yaad96/DesignFix-client/wiki#installing-srcml)的说明进行安装。 ## spmf.jar 此文件是执行 FP_MAX selectedAlgorithm(用于挖掘设计规则)所必需的。可以从该仓库或[此处](http://www.philippe-fournier-viger.com/spmf/index.php?link=download.php)下载。 **此文件应被复制/移动到项目的根目录下。** ## ruleTable.json 在项目文件夹中必须有一个名为 `ruleTable.json` 的文件,用于存储所有规则。最近为每条规则添加了 `grammar` 字段。 该字段是必需的,但对于新添加的规则会自动生成。以下是此文件的示例: ``` [ { "index": "1", "title": "All Buttons must have a title", "description": "IF a JButton is created\nTHEN it should be initialized and have a title upon creating.", "tags": [ "Labeling" ], "checkForFilesFolders": [ "src" ], "checkForFilesFoldersConstraints": "INCLUDE", "processFilesFolders": "WITHIN", // JButtons "quantifierXPathQuery": ["src:unit/src:class/src:block//src:decl_stmt/src:decl[src:type/src:name/text()=\"JButton\"]"], // JButtons with labels in constructor "constraintXPathQuery": ["src:unit/src:class/src:block//src:decl_stmt/src:decl[src:type/src:name/text()=\"JButton\" and count(src:init/src:expr/src:call/src:argument_list/src:argument)>0]"] }, { "index": "6", "title": "Communication between artifacts should be indirected through a Command", "description": "IF an Artifact needs to communicate with another artifact\nTHEN it should create a Command describing the desired action to be performed.\nEach Artifact exists in a separate shard, which may execute in parallel on a separate server. An artifact may communicate with another artifact by creating a Command which describes the action that it wishes the receiving Artifact to perform.", "tags": [ "Sharding", "Command", "Entity", "Persistence" ], "checkForFilesFolders": [ "src/com/crowdcoding/commands", "src/com/crowdcoding/entities" ], "checkForFilesFoldersConstraints": "INCLUDE", "processFilesFolders": "MIXED", "quantifierQueryType": "FIND_FROM_TEXT", // Calling constructors of all entity objects "quantifierXPathQuery": ["//src:unit/src:class[(src:annotation/src:name[text()=\"Entity\"] or src:annotation/src:name[text()=\"Subclass\"])]/src:name/text()", "//src:unit/src:class[src:super/src:extends/src:name/text()=\"Command\"]/src:block/src:class/src:block/descendant-or-self::src:decl_stmt/src:decl[src:init/src:expr/src:call/src:name/text()=\"\"]"], "constraintQueryType": "RETURN_TO_BASE", // Calling constructors of allowed entity objects", "constraintXPathQuery": ["//src:unit/src:class/src:block/src:function_decl[src:name/text()=\"execute\"]/src:parameter_list/src:parameter/src:decl/src:type/src:name[not(text()=\"String\")]/text()", "//src:unit/src:class[src:name/text()=\"\" or (src:super/src:extends/src:name/text()=\"\")]/src:name/text()", "//src:unit/src:class[src:super/src:extends/src:name/text()=\"Command\"]/src:block/src:class/src:block/descendant-or-self::src:decl_stmt/src:decl[src:init/src:expr/src:call/src:name/text()=\"\"]"] }, { "index": "11", "title": "@Entity classes must be registered in the CrowdServlet class", "description": "IF a class is an Entity class or subclass \nTHEN it must be registered in 'CrowdServlet' class by ObjectifyService.\nAll entities needs to be registered with Objectify, so that Objectify knows to persist them. The registration must be done in 'CrowdServlet.java'", "tags": [ "Entity", "Objectify", "Persistence" ], "checkForFilesFolders": [ "src/com/crowdcoding/entities", "src/com/crowdcoding/servlets" ], "checkForFilesFoldersConstraints": "INCLUDE", "processFilesFolders": "MIXED", // Entity classes "quantifierXPathQuery": ["//src:unit/src:class[(src:annotation/src:name[text()=\"Entity\"] or src:annotation/src:name[text()=\"Subclass\"])]"], "constraintQueryType": "FIND_FROM_TEXT", // Registered classes "constraintXPathQuery": ["//src:unit/src:class[src:name/text()=\"CrowdServlet\"]//src:expr_stmt/src:expr/src:call[src:name/src:name/text()=\"ObjectifyService\" and src:name/src:name/text()=\"register\"]/src:argument_list/src:argument/src:expr/src:name/src:name[1]/text()", "//src:unit/src:class[src:name/text()=\"\"]"] } ] ``` ## tagTable.json 还有一个名为 `tagTable.json` 的 JSON 文件。我们在此文件中存储有关标签的信息。以下是此文件的示例: ``` [ { "ID": "0", "tagName": "Labeling", "detail": "Rules about labeling the items used in the application. The labeling must follows special policies." }, { "ID": "1", "tagName": "Objects", "detail": "Rules about object created in the application. For each object there might be some constraints and considerations." } ] ``` ## RulePad Grammar 此系统使用 ANTLR4。 * 语法存储在 `rulePadGrammar.g4` 中 * 使用 ANTLR 生成的代码通过 `gradle` 脚本创建。 * `gradle.build` 文件位于项目的根目录中。 * 运行 `gradle generateParser` ## 在 IntelliJ 中清除搜索历史记录(用于学习设计规则) 编辑此目录中的相关 workspace xml 文件(在 MacOS 上): `~/Library/Application Support/JetBrains/IntelliJIdea2020.1/workspace` ## 使用的端口 此应用程序使用了三个端口: * 8887 用于 websocket * 3000 用于应用程序服务器(经常变动,请查看 package.json 以获取活动端口) ## 开发报告 目前,在升级依赖项方面存在一些问题。 如果更新了 devDependencies,除非更改 Webpack 的配置,否则 antlr-4 将变得不兼容。 如果仅将 "react-scripts" 更新为 "^4.0.3",则会出现有关 eslint 的警告, 可以通过向 .env 文件添加 SKIP_PREFLIGHT_CHECK=true 来移除这些警告。 在安装时,应使用 `npm install --legacy-peer-deps`。
标签:JS文件枚举, React, Syscalls, WebSocket, 云安全监控, 依赖分析, 后台面板检测, 响应拦截, 架构规范, 自定义脚本, 静态分析