Sha256: 8cabf53254a3d883333ca43eb0fef14754f0f24090d6f93154a5486cd31102f7

Contents?: true

Size: 1.49 KB

Versions: 14

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

module Headdesk
  module Checks
    #
    # Check the version of the Facebook SDK
    #
    # Facebook deprecates SDKs 2 years after they are released.
    #
    class FacebookSDK
      include Check::APK

      check_name 'facebook'
      describe 'Facebook SDK version'
      def call
        skip_check unless: -> { apk.class?('com/facebook/FacebookSdk') }
        facebook_sdk = apk.find_class('com/facebook/FacebookSdk')

        # TODO: Parse https://developers.facebook.com/docs/android/change-log-4x
        #       and fail if > 2 years old, warn if < 3 months remaining
        get_sdk_version = facebook_sdk.method('getSdkVersion').code
        describe 'com.facebook.FacebookSdk contains getSdkVersion method'
        fail_check if: -> { !get_sdk_version }

        facebook_sdks = YAML.load_file(Headdesk::FACEBOOK_SDK_VERSIONS_YAML)
        major, minor, patch = get_sdk_version.match(/const-string v0, "(\d+)\.(\d+)\.(\d+)"/).captures.map(&:to_i)

        sdk_in_use = (facebook_sdks.select do |sdk|
          sdk[:major] == major && sdk[:minor] == minor && sdk[:patch] == patch
        end).first

        describe "Found Facebook SDK version #{sdk_in_use[:version]}"
        fail_check if: -> { !sdk_in_use }

        export facebook_sdk: sdk_in_use

        describe "Facebook SDK was released in the last 2 years (using #{sdk_in_use[:version]}, released #{sdk_in_use[:date]})"
        fail_check if: -> { sdk_in_use[:date] < (Date.today - (365 * 2)) }
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
headdesk-0.12.0 lib/headdesk/checks/facebook.rb
headdesk-0.11.3 lib/headdesk/checks/facebook.rb
headdesk-0.11.2 lib/headdesk/checks/facebook.rb
headdesk-0.11.1 lib/headdesk/checks/facebook.rb
headdesk-0.11.0 lib/headdesk/checks/facebook.rb
headdesk-0.10.0 lib/headdesk/checks/facebook.rb
headdesk-0.9.0 lib/headdesk/checks/facebook.rb
headdesk-0.8.0 lib/headdesk/checks/facebook.rb
headdesk-0.7.0 lib/headdesk/checks/facebook.rb
headdesk-0.6.0 lib/headdesk/checks/facebook.rb
headdesk-0.5.2 lib/headdesk/checks/facebook.rb
headdesk-0.5.1 lib/headdesk/checks/facebook.rb
headdesk-0.5.0 lib/headdesk/checks/facebook.rb
headdesk-0.4.0 lib/headdesk/checks/facebook.rb