• linux 下代码检查工具部署使用


    Linux 下代码检查工具

    一、sonarlint 进行代码审计

    1. 安装部署jdk 安装jre 环境
      安装jdk ,设置环境变量,修改/etc/profile
    JAVA_HOME=/usr/lib/jvm/jdk-18
    CLASSPATH=$JAVA_HOME/lib/
    PATH=$PATH:$JAVA_HOME/bin 
    export PATH JAVA_HOME CLASSPATH
    
    • 1
    • 2
    • 3
    • 4

    保存文件以后,在source /etc/profile 使得生效
    代码检查

    1. 需要配置Makefile tool ,设置相关参数 生成 compile_commands.json

    vs code 文件->首选项->MakeFile

    {
        "makefile.configurations": [
            {
                "name": "selinux_permission_manager",
                 "makeArgs": ["TARGET=permission_manager_dbus_daemon" ,
                 "TOOLS_SRC=$(wildcard src/tools/*.c)" ,
                 "TOOLS=$(patsubst %.c,%,$(TOOLS_SRC))" ,
                 "CC = gcc" ,
                 "INC = -I src/include" ,
                 "LIBS = $(shell pkg-config --cflags --libs libsystemd)" ,
                 "LIBS += -lpthread -lRoseLprAPI -lsemanage -lselinux -lmount" ,
                 "CFLAGS += -g" ,
                 "DAEMON_SRC=$(wildcard src/dbus_daemon/*.c src/policy_control/*.c)" ,
                 "OBJS=$(patsubst %.c,%.o,$(DAEMON_SRC))"]
            }
        ],
        "sonarlint.pathToCompileCommands": "${workspaceFolder}/.vscode/compile_commands.json"
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19

    编译指令

    二、splint的安装。

    在安装splint的时候遇到了不少问题(注:在ubuntu下),这里我把安装工程描述一边:
    1.下载splint:http://www.splint.org/downloads/splint-3.1.2.src.tgz 这是最新的。不过我使用的是3.1.1版http://www.splint.org/downloads/binaries/splint-3.1.1.Linux.tgz 。
    2.解压包 安装:

    tar -xzf splint-3.1.1.linux.tgz

    mkdir /usr/local/splint

    cd splint-3.1.1

    ./configure --prefix=/usr/local/splint

    make install

    3.配置
    #vi ~/.bashrc
    加入:export LARCH_PATH= /usr/local/splint/share/splint/lib
    export LCLIMPORTDIR = /usr/local/splint/share/splint/import
    #source ~/.bashrc

    exprot PATH=/usr/local/splint/bin: P A T H ( 这里注意,有的说明上这样写 e x p o r t P A T H = / u s r / l o c a l / s p l i n t / b i n / s p l i n t : PATH (这里注意,有的说明上这样写export PATH=/usr/local/splint/bin/splint: PATH(这里注意,有的说明上这样写exportPATH=/usr/local/splint/bin/splint:PATH。我使用是发现不能有问题 )

    或者将~/.bashrc重新打开,将上面一句加入文件中,注销重启。完成环境变量的设置
    4.可以使用# splint abc.c

    https://blog.csdn.net/xiaowang1379214245/article/details/82688802
    https://www.cnblogs.com/LiuYanYGZ/p/11729938.html
    http://senlinzhan.github.io/2017/12/31/valgrind/

  • 相关阅读:
    股权转让项目:厦门古龙温泉山庄开发有限公司60%股权转让
    YOLOV7开源代码讲解--训练参数解释
    简述Spring Bean生命周期
    Kotlin 协程异常全局捕捉
    【JVM】JVM异常不打印堆栈信息 [ -XX:-OmitStackTraceInFastThrow ]
    【数据结构与算法分析】0基础带你学数据结构与算法分析03--栈 (Stack)
    wps 开发插件
    Angular 中的路由
    师文汇:OceanBase 4.0 产品核心能力解读
    一文搞懂kubernetes Deployment之滚动更新、回滚应用及策略;
  • 原文地址:https://blog.csdn.net/contiune/article/details/127753127