metrica
Мы используем куки, чтобы пользоваться сайтом было удобно.
Хорошо
to the top
close form

Заполните форму в два простых шага ниже:

Ваши контактные данные:

Шаг 1
Поздравляем! У вас есть промокод!

Тип желаемой лицензии:

Шаг 2
Team license
Enterprise license
** Нажимая на кнопку, вы даете согласие на обработку
своих персональных данных. См. Политику конфиденциальности
close form
Запросите информацию о ценах
Новая лицензия
Продление лицензии
--Выберите валюту--
USD
EUR
RUB
* Нажимая на кнопку, вы даете согласие на обработку
своих персональных данных. См. Политику конфиденциальности

close form
Бесплатная лицензия PVS‑Studio для специалистов Microsoft MVP
* Нажимая на кнопку, вы даете согласие на обработку
своих персональных данных. См. Политику конфиденциальности

close form
Для получения лицензии для вашего открытого
проекта заполните, пожалуйста, эту форму
* Нажимая на кнопку, вы даете согласие на обработку
своих персональных данных. См. Политику конфиденциальности

close form
Мне интересно попробовать плагин на:
* Нажимая на кнопку, вы даете согласие на обработку
своих персональных данных. См. Политику конфиденциальности

close form
check circle
Ваше сообщение отправлено.

Мы ответим вам на


Если вы так и не получили ответ, пожалуйста, проверьте папку
Spam/Junk и нажмите на письме кнопку "Не спам".
Так Вы не пропустите ответы от нашей команды.

Вебинар: Трудности при интеграции SAST, как с ними справляться - 04.04

>
>
>
Примеры ошибок, обнаруженных с помощью …

Примеры ошибок, обнаруженных с помощью диагностики V3019

V3019. It is possible that an incorrect variable is compared with null after type conversion using 'as' keyword.


SharpDevelop

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'node', 'solutionFolderNode'. SolutionNodeCommands.cs 127


public override void Run()
{
  ....
  ISolutionFolderNode solutionFolderNode =
    node as ISolutionFolderNode;

  if (node != null)
  {
    ISolutionFolder newSolutionFolder =
      solutionFolderNode.Folder.CreateFolder(....);
    solutionFolderNode.Solution.Save();
  ....
}

Similar errors can be found in some other places:

  • V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'geometry', 'g'. PathHandlerExtension.cs 578
  • V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'oldTransform', 'tg'. ModelTools.cs 420
  • V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'node', 'solutionFolderNode'. SolutionNodeCommands.cs 104

Microsoft Code Contracts

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'other', 'right'. CallerInvariant.cs 189


public override Predicate JoinWith(Predicate other)
{
  var right = other as PredicateNullness;
  if (other != null)
  {
    if (this.value == right.value)
    {
      return this;
    }
  }

  return PredicateTop.Value;
}

Similar errors can be found in some other places:

  • V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'facts', 'moreRefinedFacts'. SimplePostconditionDispatcher.cs 319
  • V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'objProvenance', 'provenance'. AssertionCrawlerAnalysis.cs 816
  • V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'prev', 'other'. NonRelationalValueAbstraction.cs 1063
  • And 7 additional diagnostic messages.

.NET Core Libraries (CoreFX)

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'comparand', 'comparedCredentialKey'. CredentialCache.cs 4007


public override bool Equals(object comparand)
{
  CredentialHostKey comparedCredentialKey =
                                  comparand as CredentialHostKey;

  if (comparand == null)
  {
    // This covers also the compared == null case
    return false;
  }

  bool equals = string.Equals(AuthenticationType,
        comparedCredentialKey.AuthenticationType, ....
  ....
}

Similar errors can be found in some other places:

  • V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'comparand', 'comparedCredentialKey'. CredentialCache.cs 497
  • V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'myObject', 'myString'. CaseInsensitiveAscii.cs 46
  • V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'a', 'nodeA'. AttributeSortOrder.cs 22
  • And 3 additional diagnostic messages.

MonoDevelop

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'o', 'sr'. MonoDevelop.Core SolutionItemReference.cs 81


public override bool Equals (object o)
{
  SolutionItemReference sr = o as SolutionItemReference;
  if (o == null)
    return false;
  return (path == sr.path) && (id == sr.id);
}

MonoDevelop

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'sender', 'selection'. MonoDevelop.Ide TasksOptionsPanel.cs 123


void OnTokenSelectionChanged (object sender, EventArgs args)
{
  TreeSelection selection = sender as TreeSelection;
  if (sender != null)
  {
    TreeIter iter;
    TreeModel model = (TreeModel)tokensStore;
    if (selection.GetSelected (out model, out iter)) {
        entryToken.Text = (string)tokensStore.GetValue (iter, 0);
        comboPriority.Active = (int)tokensStore
                                      .GetValue (iter, 1);
    } else
    {
      entryToken.Text = String.Empty;
      comboPriority.Active = (int)TaskPriority.Normal;
    }
  }
}

Similar errors can be found in some other places:

  • V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'data', 'urlMarker'. MonoDevelop.SourceEditor MarkerOperationsHandler.cs 43
  • V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'symbol', 'method'. CSharpBinding FormatStringHelper.cs 59

IronPython and IronRuby

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'value', 'strValue'. EnvironmentSingletonOps.cs 189


public static bool HasValue(RubyContext/*!*/ context,
  object/*!*/ self, object value) {
  var strValue = value as MutableString;
  if (value == null) {
    return false;
  }
  var clrStrValue = strValue.ConvertToString();
  ....
}

IronPython and IronRuby

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'node', 'scalar'. RubyConstructor.cs 230


private static RubyRegex/*!*/ ConstructRubyRegexp(
  RubyConstructor/*!*/ ctor, Node/*!*/ node) {
  ScalarNode scalar = node as ScalarNode;
  if (node == null) {
    throw RubyExceptions.CreateTypeError(
      "Can only create regex from scalar node");
  }
  Match match = _regexPattern.Match(scalar.Value);
  ....
}

.NET Compiler Platform ("Roslyn")

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'obj', 'd'. DiagnosticDescription.cs 201


public override bool Equals(object obj)
{
  var d = obj as DiagnosticDescription;

  if (obj == null)
    return false;

  if (!_code.Equals(d._code))
    return false;
  ....
}

.NET Compiler Platform ("Roslyn")

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'other', 'otherResourceString'. LocalizableResourceString.cs 121


protected override bool AreEqual(object other)
{
  var otherResourceString = other as LocalizableResourceString;
  return
    other != null &&
    _nameOfLocalizableResource ==
      otherResourceString._nameOfLocalizableResource &&
    _resourceManager == otherResourceString._resourceManager &&
    _resourceSource == otherResourceString._resourceSource &&
    ....
}

.NET Compiler Platform ("Roslyn")

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'parentStartTag', 'parentElement'. XmlTagCompletionCommandHandler.cs 123


private bool HasMatchingEndTag(
  XmlElementStartTagSyntax parentStartTag)
{
  if (parentStartTag == null)
  {
    return false;
  }

  var parentElement = parentStartTag.Parent as XmlElementSyntax;
  if (parentStartTag == null)
  {
    return false;
  }
  var endTag = parentElement.EndTag;
  ....
}

This error can also be detected in a different way. The analyzer generates such a message for this code fragment: V3021 There are two 'if' statements with identical conditional expressions. The first 'if' statement contains method return. This means that the second 'if' statement is senseless XmlTagCompletionCommandHandler.cs 117


Sony ATF

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'd', 'box'. Atf.Gui.Wpf.vs2010 PasswordBoxBehavior.cs 38


private static void OnBoundPasswordChanged(DependencyObject d,
                      DependencyPropertyChangedEventArgs e)
{
    PasswordBox box = d as PasswordBox;

    if (d == null || !GetBindPassword(d))
    {
        return;
    }

    box.PasswordChanged -= HandlePasswordChanged;
    ....
}

Space Engineers

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'builder', 'ob'. Sandbox.Game MyWeaponBlockDefinition.cs 21


protected override void Init(
                         MyObjectBuilder_DefinitionBase builder)
{
  base.Init(builder);

  var ob = builder as MyObjectBuilder_WeaponBlockDefinition;
  Debug.Assert(builder != null);                           // <=

  WeaponDefinitionId = new MyDefinitionId(
                         ob.WeaponDefinitionId.Type,
                         ob.WeaponDefinitionId.Subtype);
  ResourceSinkGroup = MyStringHash.GetOrCompute(
                        ob.ResourceSinkGroup);
  InventoryMaxVolume = ob.InventoryMaxVolume;
}

Space Engineers

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'item', 'actionsItem'. Sandbox.Game MyGuiControlToolbar.cs 511


private void contextMenu_ItemClicked(....)
{
  ....
  var actionsItem = item as MyToolbarItemActions;
  if (item != null)                                       // <=
  {
    if (idx < 0 || idx >= actionsItem
                          .PossibleActions(ShownToolbar
                                             .ToolbarType)
                          .Count)
      RemoveToolbarItem(slot);
  ....
  }
  ....
}

Similar errors can be found in some other places:

  • V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'ob', 'objectBuilder'. Sandbox.Game MyBlockNavigationDefinition.cs 172
  • V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'Owner', 'character'. Sandbox.Game MyWelder.cs 232

Old NASA World Wind (C#)

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'obj', 'robj'. RenderableObject.cs 199


public int CompareTo(object obj)
{
  RenderableObject robj = obj as RenderableObject;
  if(obj == null)   // <=
    return 1;
  return this.m_renderPriority.CompareTo(robj.RenderPriority);
}

FlashDevelop

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'item', 'val'. WizardHelper.cs 67


public static void SetControlValue(....)
{
  ....
  string val = item as string;
  if (item == null) continue;
  ....
}

MSBuild

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'obj', 'name'. AssemblyRemapping.cs 64


public override bool Equals(object obj)
{
   AssemblyNameExtension name = obj as AssemblyNameExtension;
   if (obj == null)  // <=
   {
     return false;
   }
   ....
}

Mono

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'o', 'umc'. UrlMembershipCondition.cs 111


public override bool Equals (object o)
{
  UrlMembershipCondition umc = (o as UrlMembershipCondition);
  if (o == null)                                      // <=
    return false;

  ....

  return (String.Compare (u, 0, umc.Url, ....) == 0); // <=
}

Mono

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'v1', 'cmp'. Array.cs 1487


static bool QSortArrange (.... ref object v0, int hi,
                          ref object v1, ....)
{
  IComparable cmp;
  ....
  cmp = v1 as IComparable;

  if (v1 == null || cmp.CompareTo (v0) < 0) {
    ....
  }
  ....
}

Microsoft Bot Builder

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'step', 'prop'. FieldReflector.cs 231


protected Type StepType(object step)
{
  var field = step as FieldInfo;
  var prop = step as PropertyInfo;
  return (step == null ? null :
         (field == null ? prop.PropertyType :  // <=
                          field.FieldType));
}

PowerShell

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'j', 'child'. System.Management.Automation Job.cs 1876


internal List<Job> GetJobsForComputer(String computerName)
{
  ....
  foreach (Job j in ChildJobs)
  {
    PSRemotingChildJob child = j as PSRemotingChildJob;
    if (j == null) continue;
    if (String.Equals(child.Runspace
                           .ConnectionInfo
                           .ComputerName,
                      computerName,
                      StringComparison.OrdinalIgnoreCase))
    {
      returnJobList.Add(child);
    }
  }
  return returnJobList;
}

Similar errors can be found in some other places:

  • V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'j', 'child'. System.Management.Automation Job.cs 1900
  • V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'j', 'child'. System.Management.Automation Job.cs 1923

Media Portal 2

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'obj', 'other'. EpisodeInfo.cs 560


public override bool Equals(object obj)
{
  EpisodeInfo other = obj as EpisodeInfo;
  if (obj == null) return false;
  if (TvdbId > 0 && other.TvdbId > 0)
    return TvdbId == other.TvdbId;
  ....
}

PascalABC.NET

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'baseScope', 'this.baseScope'. CodeCompletion SymTable.cs 3497


public TypeScope(...., SymScope baseScope)
{
  ....
  this.baseScope = baseScope as TypeScope;
  ....
  if (baseScope == null)
  {
    ....
  }
  ....
}

Similar errors can be found in some other places:

  • V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'returned_scope', 'ts'. CodeCompletion ExpressionVisitor.cs 1595
  • V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'returned_scope', 'tmp_scope'. CodeCompletion DomSyntaxTreeVisitor.cs 1553
  • V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'returned_scope', 'ts.elementType'. CodeCompletion DomSyntaxTreeVisitor.cs 2815
  • And 6 additional diagnostic messages.

Logify Alert Clients

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'sender', 'source'. BreadcrumbsRecorder.cs 86


void KeyDown(object sender, KeyEventArgs e) {
  FrameworkElement source = sender as FrameworkElement;
  if(!IsActive || (sender == null))
      return;
  Dictionary<string, string> properties =
    CollectCommonProperties(source, e);
  LogKeyboard(properties, e, false,
           CheckPasswordElement(e.OriginalSource as UIElement));
}

Similar errors can be found in some other places:

  • V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'sender', 'source'. BreadcrumbsRecorder.cs 94
  • V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'sender', 'source'. BreadcrumbsRecorder.cs 102
  • V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'sender', 'source'. BreadcrumbsRecorder.cs 110
  • And 2 additional diagnostic messages.

Unity C# reference source code

V3019 CWE-697 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'obj', 'newResolution'. GameViewSizesMenuItemProvider.cs 104


private static GameViewSize CastToGameViewSize(object obj)
{
  GameViewSize newResolution = obj as GameViewSize;
  if (obj == null)
  {
    Debug.LogError("Incorrect input");
    return null;
  }
  return newResolution;
}

Telerik UI for UWP

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'dragDropElement', 'uiDragDropElement'. DragDrop.cs 91


internal static void StartDrag(....)
{
  var dragDropElement = sender as IDragDropElement;
  ....
  UIElement uiDragDropElement = dragDropElement as UIElement;
  ....
  if (dragDropElement == null ||
      !dragDropElement.CanStartDrag(trigger, initializeContext))
  {
    return;
  }
  ....
  var relativeStartDragPosition = e.GetCurrentPoint(uiDragDropElement).Position;
  var dragPositionMode = DragDrop.GetDragPositionMode(uiDragDropElement);
  ....
}

QuantConnect Lean

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'buyingPowerModel', 'futureMarginModel'. BasicTemplateFuturesAlgorithm.cs 105


public override void OnEndOfAlgorithm()
{
  var buyingPowerModel = Securities[_contractSymbol].BuyingPowerModel;
  var futureMarginModel = buyingPowerModel as FutureMarginModel;
  if (buyingPowerModel == null)
  {
    throw new Exception($"Invalid buying power model. " +
                        $"Found: {buyingPowerModel.GetType().Name}. " +
                        $"Expected: {nameof(FutureMarginModel)}");
  }
  ....
}

Unity C# reference source code

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'targetItem', 'hierarchyTargetItem'. AssetOrGameObjectTreeViewDragging.cs 153


public override DragAndDropVisualMode DoDrag(....)
{
  var hierarchyTargetItem = targetItem as GameObjectTreeViewItem;

  if (m_CustomDragHandling != null)
  {
    DragAndDropVisualMode dragResult =
      m_CustomDragHandling(parentItem as GameObjectTreeViewItem,
                           hierarchyTargetItem,
                           ....);
    ....
  }
  DragAndDropVisualMode dragSceneResult =
    DoDragScenes(parentItem as GameObjectTreeViewItem,
                 hierarchyTargetItem,
                 ....);

  if (   targetItem != null
      && !IsDropTargetUserModifiable(hierarchyTargetItem, dropPos)) // <=
  {
    return DragAndDropVisualMode.Rejected;
  }
  ....
}

AWS SDK for .NET

V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'coreSTSClient', 'samlCoreSTSClient'. FederatedAWSCredentials.cs 219


private CredentialsRefreshState Authenticate(ICredentials userCredential)
{
  ....
  ICoreAmazonSTS coreSTSClient = ....;

  var samlCoreSTSClient
#if NETSTANDARD
    = coreSTSClient as ICoreAmazonSTS_SAML;
  if (coreSTSClient == null)                 // <=
  {
    throw new NotImplementedException(
      "The currently loaded version of AWSSDK.SecurityToken
       doesn't support SAML authentication.");
  }
#else
    = coreSTSClient;
#endif

  ....
}