* Test 1.4

* Update Dockerfile

* Update Dockerfile

* Unit tests

* Update command

* Add symlink

* Update execution script

* Update Dockerfile

* No need to remove infer-out

* Disable unit tests temporarily

* Update the run script

* Fix wsl incremental (#163)

* Update SourceFile.cs

* Update SourceFiles with unix-like path

* Update SourceFile.cs

* Update inferconfig

* Add timeout for slower agents

* Fix pipeline name

* Revert job timeout

It was due to the signing service being down, not because of the build agents

Co-authored-by: Xiaoyu Liu <lixiaoyu@microsoft.com>
This commit is contained in:
Xin Shi 2022-09-30 12:21:04 -07:00 коммит произвёл GitHub
Родитель 598d9b6cc9
Коммит 64dc14a754
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 25 добавлений и 74 удалений

Просмотреть файл

@ -76,4 +76,3 @@ steps:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/infer-release/infersharp-linux64-version.tar.gz'
ArtifactName: 'release'
publishLocation: 'Container'

Просмотреть файл

@ -9,7 +9,11 @@
}
],
"enable-issue-type" : [ "PULSE_RESOURCE_LEAK", "TAINT_ERROR", "NULLPTR_DEREFERENCE", "THREAD_SAFETY_VIOLATION" ],
"disable-issue-type" : [ "DOTNET_RESOURCE_LEAK", "PULSE_UNINITIALIZED_VALUE" ],
"debug-level" : 1,
"sarif" : true,
"pulse" : true,
"biabduction" : false,
"pulse-taint-policies": [
{ "short_description": "SQL injection risk",
"taint_flows": [

Просмотреть файл

@ -803,37 +803,6 @@ namespace Cilsil.Test.E2E
GetString(expectedError), true);
}
/// <summary>
/// Validates the use of Infer models for pre-compiled code during analysis. The model
/// tested here is String.IsNullOrWhiteSpace, but the purpose of the test is to verify
/// that any model can be used in analysis.
/// </summary>
/// <param name="modelOperator">Defines whether the model's null check is logically
/// negated.</param>
/// <param name="expectedError">The expected error.</param>
[DataRow("!", InferError.None)]
[DataRow("", InferError.NULL_DEREFERENCE)]
[DataTestMethod]
public void ModelIsNullOrWhitespace(string modelOperator, InferError expectedError)
{
TestRunManager.Run(
InitVars(state: TestClassState.Null,
firstLocalVarType: VarType.Boolean,
firstLocalVarValue: GetString(
ModelMethod.String__IsNullOrWhiteSpace,
args: new string[]
{
"null"
},
withEnding: true)) +
GenerateSingleComparisonIfCondition(BooleanTestType.Unary,
firstOperator: modelOperator,
secondOperator: "==",
"true") +
DerefObject(VarName.Tc),
GetString(expectedError));
}
/// <summary>
/// Validates our translation of CastClass.
/// </summary>

Просмотреть файл

@ -189,7 +189,7 @@ namespace Cilsil.Test
Directory.CreateDirectory(Path.Combine(InferOutFolder, "captured"));
RunCommand(
"infer",
$"analyzejson --debug --cfg-json {cfgJson} --tenv-json {tenvJson} " +
$"run --debug --cfg-json {cfgJson} --tenv-json {tenvJson} " +
$"--enable-issue-type CLASS_CAST_EXCEPTION",
out stdout,
out stderr);

Просмотреть файл

@ -53,7 +53,7 @@ namespace Cilsil.Sil
return new SourceFile()
{
PathType = PathType.Relative,
Path = path
Path = path.Replace('\\','/')
};
}
}

Просмотреть файл

@ -35,7 +35,10 @@ RUN opam init --reinit --bare --disable-sandboxing
# Download the latest Infer master
RUN cd / && \
git clone https://github.com/facebook/infer.git
git clone https://github.com/xi-liu-ds/infer.git && \
cd infer && \
git checkout xi-liu-ds/pull_incre && \
cd ..
# build in non-optimized mode by default to speed up build times
ENV BUILD_MODE=dev
@ -65,9 +68,7 @@ ENV PATH /infer-release/usr/local/bin:${PATH}
COPY . .
RUN cd /
RUN chmod +x build_csharp_models.sh && ./build_csharp_models.sh
RUN cp /infer-out/models.sql /infer-release/usr/local/lib/infer/infer/lib/models.sql
RUN dotnet test Cilsil.Test/Cilsil.Test.csproj
#RUN dotnet test Cilsil.Test/Cilsil.Test.csproj
RUN dotnet publish -c Release Cilsil/Cilsil.csproj -r linux-x64
RUN dotnet build Examples/Examples/Examples.csproj
@ -75,9 +76,11 @@ FROM debian:bullseye-slim AS release
RUN apt-get update && apt-get install --yes --no-install-recommends curl ca-certificates
WORKDIR infersharp
COPY --from=backend /infer-release/usr/local /infersharp/infer
RUN ln -s /infersharp/infer/bin/infer /usr/local/bin/infer
ENV PATH /infersharp/infer/bin:${PATH}
COPY --from=backend /Examples/Examples/bin/Debug/net5.0/ /infersharp/Examples/
COPY --from=backend /Cilsil/bin/Release/net5.0/linux-x64/publish/ /infersharp/Cilsil/
COPY --from=backend .inferconfig /infersharp/
COPY --from=backend run_infersharp.sh /infersharp/
COPY --from=backend /.build/NOTICE.txt /
COPY --from=backend LICENSE /
COPY --from=backend LICENSE /

Двоичные данные
changed_files_index.txt Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -7,52 +7,30 @@ set -e
# Check if we have enough arguments.
if [ "$#" -lt 1 ]; then
echo "run_infersharp.sh <dll_folder_path> [--output-folder <sarif_output_folder_path> --enable-null-dereference --enable-dotnet-resource-leak --enable-thread-safety-violation --sarif] -- requires 1 argument (dll_folder_path)"
exit
echo "run_infersharp.sh <dll_folder_path> <options - see https://fbinfer.com/docs/man-infer-run#OPTIONS>"
exit
fi
infer_args_list=("--enable-issue-type NULLPTR_DEREFERENCE" "--enable-issue-type DOTNET_RESOURCE_LEAK" "--enable-issue-type THREAD_SAFETY_VIOLATION")
output_folder=""
infer_args=""
# Clear issue types if specific issue is mentioned in arguments
for v in "$@"
do
if [[ $v == --enable* ]]; then
infer_args_list=()
fi
done
# Parse arguments
if [ "$#" -gt 1 ]; then
i=2
while [ $i -le $# ]
do
if [ ${!i} == "--enable-null-dereference" ]; then
infer_args_list+=("--enable-issue-type NULLPTR_DEREFERENCE")
elif [ ${!i} == "--enable-dotnet-resource-leak" ]; then
infer_args_list+=("--enable-issue-type DOTNET_RESOURCE_LEAK")
elif [ ${!i} == "--enable-thread-safety-violation" ]; then
infer_args_list+=("--enable-issue-type THREAD_SAFETY_VIOLATION")
elif [ ${!i} == "--output-folder" ]; then
do
if [ ${!i} == "--output-folder" ]; then
((i++))
output_folder=${!i}
fi
output_folder=${!i}
else
infer_args+="${!i} "
fi
((i++))
done
fi
# Dynamically create the issue types
infer_args=""
for infer_arg in "${infer_args_list[@]}"
do
infer_args="$infer_args $infer_arg"
done
echo "Processing {$1}"
# Preparation
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$parent_path"
if [ -d infer-out ]; then rm -Rf infer-out; fi
if [ -d infer-staging ]; then rm -Rf infer-staging; fi
echo -e "Copying binaries to a staging folder...\n"
@ -62,9 +40,7 @@ cp -r "$1" infer-staging
echo -e "Code translation started..."
./Cilsil/Cilsil translate infer-staging --outcfg infer-staging/cfg.json --outtenv infer-staging/tenv.json --cfgtxt infer-staging/cfg.txt --extprogress
echo -e "Code translation completed. Analyzing...\n"
$parent_path/infer/lib/infer/infer/bin/infer capture
mkdir infer-out/captured
$parent_path/infer/lib/infer/infer/bin/infer $($parent_path/infer/lib/infer/infer/bin/infer help --list-issue-types 2> /dev/null | grep ':true:' | cut -d ':' -f 1 | sed -e 's/^/--disable-issue-type /') $infer_args --pulse --no-biabduction --debug-level 1 --sarif analyzejson --cfg-json infer-staging/cfg.json --tenv-json infer-staging/tenv.json
infer run $infer_args --cfg-json infer-staging/cfg.json --tenv-json infer-staging/tenv.json
if [ "$output_folder" != "" ]; then
if [ ! -d "$output_folder" ]; then