356 Commits
Author SHA1 Message Date
Mr.XandVictor M. Alvarez 5e8a8ea41f Add yr_get_version to report the version of the library loaded at runtime (#2247)
YR_MAJOR_VERSION, YR_MINOR_VERSION and YR_MICRO_VERSION are fixed when the
caller is compiled, so a program linked against a shared libyara has no way
to tell which version it actually loaded. Distros ship libyara.so in its own
package precisely so it can be updated independently of its consumers, which
is exactly the case the macros cannot describe.

Add yr_get_version(), which reports the version of the library that is
actually loaded. Any argument may be NULL if the caller does not need that
component, and since the function touches no global state it can be called
before yr_initialize.

Closes #2136

---------

Co-authored-by: Victor M. Alvarez <[email protected]>
2026-09-23 11:48:49 +02:00
Mr.X 25a50bd63c elf: expose nine more e_machine values (#2248)
elf.machine can hold any value from the ELF header, but the module only
named 14 of them, so a rule targeting anything else had to hardcode the
number or drop the module and match the header bytes by hand.

Add the architectures from the issue: PARISC, SPARC32PLUS, S390, MCORE,
SH, SPARCV9, ARC_COMPACT, BPF and LOONGARCH.

0x27 is exposed under both EM_MCORE and EM_RCE. EM_RCE is the name it was
originally registered under and still what some toolchains emit, so a rule
written against either name works.

Closes #2149
2026-09-23 10:04:28 +02:00
Cole Munz 99817aeb5d docs: document the YR_RE_SCAN_LIMIT regular expression scan limit (#2223)
Fixes #2194.

The regexp engines cap how much data they scan at `YR_RE_SCAN_LIMIT` (4096 bytes, defined in `libyara/include/yara/limits.h`), so a match that needs more than that simply isn't reported. @plusvic pointed at the constant in the issue thread, but the limit isn't mentioned anywhere in the docs, which was the reporter's actual complaint: rules with wide wildcards fail silently and there's nothing in the manual explaining why.

This adds a warning box to the "Regular expressions" section of writingrules.rst stating the default limit, the silent-miss behavior, and that it can be raised at compile time.

Checked against HEAD (fa372eb) before writing the note:

- built yara and ran `/foo.*bar/` over a file with `foo` and `bar` 4000 bytes apart (matches) and one with them 5000 bytes apart (no match, no error, exit 0)
- rebuilt with `CPPFLAGS='-DYR_RE_SCAN_LIMIT=8192'`: the 5000-byte gap now matches and a 9000-byte one doesn't, so the compile-time override wording is accurate
- sphinx-build runs with no new warnings and the box renders at the end of the regexp section
2026-07-14 12:23:03 +02:00
Emilien Breton 646cf50e50 docs: fix typo (#2179) 2025-11-10 17:10:39 +01:00
duckie 91fda4f2ed Remove the libyara from path libyara/Makefile.am (#2129)
The file is no longer present on that path and moved to root of project.
Fixing the docs so it does'nt cause confusion to others like it did to
me.
2025-01-13 10:10:52 +01:00
utkonos ef8f1de92e Replace stray markdown with correct RST (#2132) 2025-01-13 10:10:16 +01:00
Victor M. Alvarez 610e88fb75 Fix typo in documentation. 2024-12-11 11:10:46 +01:00
zdwg42 3a60f2dd8c Remove dotnet configure instructions since it's enabled by default now (#2122) 2024-12-02 21:10:06 +01:00
Alexander J 2c9a728ada typos in docs/writingrules.rst (#2110) 2024-09-24 20:10:23 +02:00
Victor M. Alvarez 1628e61f8e Bump version to 4.5.2 2024-09-10 10:44:46 +02:00
Tad KellerandTad Keller 79954d33e4 use new module macros in docs (#2100)
Co-authored-by: Tad Keller <[email protected]>
2024-08-16 10:05:01 +02:00
Wes 6936a2a528 docs: minor updates to xor (#2098) 2024-08-04 22:44:25 +02:00
Victor M. Alvarez 17fc88ef48 Remove all references to ERROR_TOO_MANY_SCAN_THREADS
This error code is not used anymore. Closes #2068.
2024-08-02 10:01:16 +02:00
Victor M. Alvarez 0e5b6bb966 Bump version to 4.5.1 2024-05-25 12:23:51 +02:00
Tom Lancaster 5f2a2213ac Attempt to fix docs adding --strict-escape to CLI help and main yara docs (#2077) 2024-05-18 12:07:23 +02:00
Tom Lancaster 7cf3d2fefa Modifying yara-python docs to reflect existence of strict_escape bool (#2079) 2024-05-18 12:04:32 +02:00
Vojtěch Dvořák adf3ddeaee Updated writingmodules.rst - replaced fetch_data by the new func (#2071) 2024-04-30 08:50:06 +02:00
Victor M. Alvarez 7fa7465675 Add requirements.txt for documentation. 2024-03-26 19:19:47 +01:00
Victor M. Alvarez a1883addcb Update example in yara-python's documentation.
As discussed in https://github.com/VirusTotal/yara-python/issues/247, the example using `StringIO` worked fine in Python 2, but ti doesn't work in Python 3. Now that Python 2 is mostly dead, update the example.
2024-02-29 13:08:03 +01:00
Victor M. Alvarez 8fa55cde4c Bump version number to 4.5.0 2024-02-13 12:33:22 +01:00
Tom Lancaster e4372d3a54 typo fix (#2039) 2024-02-07 16:56:48 +01:00
Vincent Thiberville cceb5019ba Fix segfault in math module when scanning a process that dies during scan (#2016)
* fix: check nullity of first block in math module

This module retrieves the first block of memory to do some validation on
parameters. However, contrary to for example the hash module, the block
value is not checked. This can lead, if for example scanning a process
and having the process die during the scan, to a SIGSEGV/Null access
violation, as the first block call will return NULL.

This bug manifests in surprising ways. Since yara runs by default
evaluation of condition in a try catch block, this bug is actually
caught by the try catch block, and a surprising "ERROR_COULD_NOT_MAP_FILE"
error is then returned.

In addition, since the try catch bypasses the whole stack, this leads to
a memory leak that can add up as more instances of this bug is triggered.

* fix: check first block in magic module

For the magic module, this bug (see previous commit) is less reachable,
since if the SCAN_FLAGS_PROCESS_MEMORY is set, we do not reach this
code. However, with a custom block iterator and without this flag, the
block value could be NULL.

* doc: update doc example on how to retrieve first memory block
2023-11-29 17:48:48 +01:00
Jacob Latonis 2f34978aaf docs: added global examples for count() and mode() (#2014)
I noticed a few of the functions that had global versions to search the whole file were missing examples, I have added them
2023-11-29 02:25:32 +01:00
Victor M. Alvarez 3772b87b59 Remove extra argument in documentation for the pe.imports(import_flag, dll_name) function 2023-11-16 16:57:54 +01:00
Cake Xu 7d8e0cc6c6 Fix 2 errors for the document: (#1968)
1. Depending on the context the "bar" should be "foo" because foo is a structure while bar is just a string.
2. The module_object's name is wrong.
2023-10-06 11:02:46 +02:00
John 52e4f1c8f3 Revert "LNK Module (#1957)"
This reverts commit 8ce0c6c4eb. See comments in https://github.com/VirusTotal/yara/pull/1957 for more context.
2023-10-06 11:01:02 +02:00
Wesley Shields d875f71a55 Add docs for unreferenced strings. (#1958)
* Add docs for unreferenced strings.

* Add example for unreferenced string.
2023-09-02 20:11:32 +02:00
John 8ce0c6c4eb LNK Module (#1957)
* LNK module initial commit

* Update atom logic to properly score [A-Z]

The documentation says `Bytes [a-zA-Z] contribute 18 points each`, but it looks like in the code that only `[a-z]` is given 18 points, whereas `[A-Z]` is given 20 points. This commit will make sure these ranges have the proper scoring as expected.

* Add test for comparing atom quality ABCD == abcd

Add test entry which compares the atom quality of "ABCD" and "abcd" and asserts that they are equal.

* Update test-atoms.c

* Revert "Update atom logic to properly score [A-Z]"

This reverts commit bf7130ff0b.

* Revert "Add test for comparing atom quality ABCD == abcd"

This reverts commit 181dbf2326.

* Revert "Update test-atoms.c"

This reverts commit 81239034b3.

* Test

* Revert "Test"

This reverts commit 1c53212b63.

* Add objects for LinkFlags parsing

Also fixed `DWORD` compiling error, and replaced with `uint32_t` types.

* Add file attribute flags

* Start hotkey parsing code

* Add the rest of the hotkey values

* Add initial test case for LNK module

Using the sample LNK from the MS standard for LNK files for testing, and putting in an initial test:
https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-SHLLINK/%5bMS-SHLLINK%5d.pdf

* Add initial LNK tests

* Add has_hotkey variable

* Formatting

* Fix timestamps set

Previous version always seemed to be an hour (3600 seconds) off what it should have been. This commit adds a test to make sure it's getting the right value.

I don't know why its always an hour off, but this should fix it!

* Refactor hotkey char select into its own function

* Add a couple of comments

* Add min size for parsing LNK

All the mandatory LNK header bytes add up to 76 bytes, and as such we won't parse an LNK file unless it is at least 76 bytes in length

* Add LinkTargetIDList parsing

* Begin working on code for LinkInfo parsing

* Refactor code into header + util files

Moving a lot of the definitions over to a separate header file to keep the main code clean.

Also following the PE module's structure of having a separate `lnk_utils` file to deal with some of the convenient functions it provides.

* Starting VolumeID parsing

* Adding free statement

* Add some VolumeID tests and fix free error

* Finish parsing VolumeID

* Parse LocalBasePath

* Refactor to prevent unsafe memory copying

Start taking into account the remaining size in the block being scanned, to make sure we don't break anything when dereferencing pointers.

* Parse CommonPathSuffix

Also create empty function for when we need to parse CommonNetworkRelativeLink

* Parse LocalBasePathUnicode and CommonPathSuffixUnicode

NOTE: these will need some testing before this will be production ready, as I'm making a lot of assumptions here.

* Return size of LinkInfo section

* Add StringData parsing

* Add initial code for parsing ExtraData section

Only parsing `TrackerDataBlock` at the moment, but setting up values in advance of setting up the other structures/parsers

* Add the remaining ExtraData structures

In some cases I don't make a structure where the parsing function will just handle the data (e.g. where there is variable data).

I will likely also ignore PropertyStore for now as that has separate documentation to parse it.

* More specific parsing of Droid GUIDs

* Move code out of VolumeID parsing indent

The rest of the LinkInfo section wasn't parsing unless a VolumeID was present, which shouldn't be how it works.

* Remove incorrect CommonNetworkRelativeLinkOffset setting

Also add structure for CommonNetworkRelativeLink parsing

* Implement CommonNetworkRelativeLink parsing

And add a couple of test cases for it

* Formatting

* Make LinkInfo parsing memory safe

* Remove unnecessary constant

* Make StringData parsing memory safe

Also convert `block_data_size_remaining` to `int` from `size_t`. This is because we don't want to underflow the `size_t` type, and assume we have more data left than we actually do.

* Fix up block data size remaining calculations in ExtraData

* Add more constants

* Add in overlay variable

* Make current ExtraData function memory safe

* Setup switch/case for ExtraData parsing

* ConsoleDataBlock parsing

* Add ConsoleFedData parsing

* Convert tracker data to struct and add more fields

* Add extra fields to current ExtraData structures

* Refactor structures

* Rename sample LNKs

* Refactor into parse_volume_id

* Parse DarwinData and fixed up block struct entries

* Add is_malformed entry

Checks whether a LNK has failed parsing due to it being malformed.

* Add overlay test case

* Parse EnvironmentVariableDataBlock

* Parse IconEnvironmentDataBlock

* Add KnownFolderDataBlock parsing

* Add placeholder parsing for PropertyDataStoreBlock

* Parse ShimDataBlock

* Parse SpecialFolderDataBlock

* Remove id_list_ptr var

* Refactor into its own function to parse IDList

* Parse VistaAndAboveIDListDataBlock

* Remove printf

* Refactor item_id_list into structure

* Add LinkInfoFlags as external variables

* Only process relevant link info if flags set

* Update StringData to also accept ASCII

I assumed it would only be ASCII, but the `IsUnicode` flag can help indicate what type of string it is.

* Only parse ExtraData if there is data left

* Retype to strings

* Fix environment var data parsing

I thought wchar_t was 16 bits, but turns out it can also be 32 bits... I'll need to change up other routines to take this into account as well

* Move inside if statement to prevent setting

* Fix icon env unicode issue

* Convert remaining wchar_t struct entries

* Add ExtraData test cases

* Add ExtraData tests (2)

* Make sure timestamps are UTC

* Start LNK module documentation

* Add ShowCommand constants

* Finish documenting LNK headers

* Change test to flag comparison

* Correct structure names

* Update test-lnk.c

* Document LinkInfo section

* Document StringData

* Add more constants

* Document ConsoleData

* Update lnk.rst

* Finish documenting LNK module

* Some extra comments

* Update lnk.rst

* Apply clang formatting

* Removed test for now

* Add more flags and renamed console_fe_data

* Formatting

* Update comment on PropertyStoreData

* Change variable names due to potential clashes

Changed the variables used in header files:
- Reserved1
- Reserved2
- Unused1
- Unused2

The CI/CD seems to fail with these values as a default, so I'm hoping changing them fixes things

* Change packing to address misaligned pointer error

* Add LNK module to VS Projects

* Changed `block_data_size_remaining` to `unsigned int`

Make variable `unsigned int` instead of just `int` to prevent the value being negative.

* Begin removing static of strings

Starting with the ones I can test, by dynamically allocating memory after doing the check, I'm removing the possibility of there being a buffer overflow on this data.

* Dynamically allocate `volume_id_data`

* Remove more statically typed char arrays

* Dynamically allocate unicode strings

Previously were statically set in length, now dynamically allocated

* Add clearer comment

* Add todo

* Add `yr_` prefix to necessary functions

Due to #1762, needed to add `yr_` as a prefix to functions like `set_string`

* Convert 'unsigned int' to `uint32_t`

* Make constants have consistent casing

* Add extra checks on block size remaining

I found a case where a function returned a section size that was greater than the remaining block size, which caused a crash. This patch checks each value returned to make sure the next stage doesn't fail to parse.

* Fix docs for icon_location

Add `lnk.` prefix to `icon_location` variable

* Add LNK module back in

* Correct LNK module source path

* Add lnk_utils to modules list

And update other libyara auto changes

* Add LNK module tests

* Fix up LNK test in Makefile

* Fix typo in test LNK

* Attempt to fix bazel build

* Testing to see why Bazel build fails

* Revert removing tests

It seems even one test gives the error `There were tests whose specified size is too big. Use the --test_verbose_timeout_warnings command line option to see which ones these are.`

* Include LNK module in BUILD.bazel

* Add missing deps line

* Add lnk.h to Makefile

* Add lnk.h to yara.bzl

* Add lnk_utils.h to yara.bzl

* Revert automatic changes

Change some C/header files that got automatically changed while compiling YARA to the same that they are on the main branch

* Include lnk_utils in Makefile

* Convert some console data variables to signed and update docs

Some variables in the console data section are actually signed variables. So I've converted them to `int16_t` instead of `uint16_t`, added some test cases to make sure these values are properly parsed, and added some examples in the docs.

* Fix typo for window_size_y

* Add flags for LNK module

* Add extra time tests

Add tests for access time and write time

* Temporary update for debugging

Attempting to update this temporarily in order to test big endian issues on this branch - revert before merging

* Revert "Temporary update for debugging"

This reverts commit 2120c7e2e5.

* Temporary change for debugging

* Change order

* Temporarily disable most tests

* Initial big endian test fix

* LNK header endian fix

* Update test-lnk.c

* Fix up time conversion function calls

* Re-enable item ID tests

* Focus on item_id_list_size test

* Fix endianness of parse_link_target_id_list

* Fix endianness of parse_id_list

* Fix endianness of link_info

* Finish applying endianness fixes

Enabled all tests now

* Roll back to test console data and string data

* Add missing endianness conversion

* Re-enable all tests

* Revert back to original state
2023-08-25 09:05:48 +02:00
John c41906bb13 Revert "LNK module (#1732)"
This reverts commit 97fd691086.
2023-08-24 09:55:14 +02:00
John 97fd691086 LNK module (#1732)
* LNK module initial commit

* Update atom logic to properly score [A-Z]

The documentation says `Bytes [a-zA-Z] contribute 18 points each`, but it looks like in the code that only `[a-z]` is given 18 points, whereas `[A-Z]` is given 20 points. This commit will make sure these ranges have the proper scoring as expected.

* Add test for comparing atom quality ABCD == abcd

Add test entry which compares the atom quality of "ABCD" and "abcd" and asserts that they are equal.

* Update test-atoms.c

* Revert "Update atom logic to properly score [A-Z]"

This reverts commit bf7130ff0b.

* Revert "Add test for comparing atom quality ABCD == abcd"

This reverts commit 181dbf2326.

* Revert "Update test-atoms.c"

This reverts commit 81239034b3.

* Test

* Revert "Test"

This reverts commit 1c53212b63.

* Add objects for LinkFlags parsing

Also fixed `DWORD` compiling error, and replaced with `uint32_t` types.

* Add file attribute flags

* Start hotkey parsing code

* Add the rest of the hotkey values

* Add initial test case for LNK module

Using the sample LNK from the MS standard for LNK files for testing, and putting in an initial test:
https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-SHLLINK/%5bMS-SHLLINK%5d.pdf

* Add initial LNK tests

* Add has_hotkey variable

* Formatting

* Fix timestamps set

Previous version always seemed to be an hour (3600 seconds) off what it should have been. This commit adds a test to make sure it's getting the right value.

I don't know why its always an hour off, but this should fix it!

* Refactor hotkey char select into its own function

* Add a couple of comments

* Add min size for parsing LNK

All the mandatory LNK header bytes add up to 76 bytes, and as such we won't parse an LNK file unless it is at least 76 bytes in length

* Add LinkTargetIDList parsing

* Begin working on code for LinkInfo parsing

* Refactor code into header + util files

Moving a lot of the definitions over to a separate header file to keep the main code clean.

Also following the PE module's structure of having a separate `lnk_utils` file to deal with some of the convenient functions it provides.

* Starting VolumeID parsing

* Adding free statement

* Add some VolumeID tests and fix free error

* Finish parsing VolumeID

* Parse LocalBasePath

* Refactor to prevent unsafe memory copying

Start taking into account the remaining size in the block being scanned, to make sure we don't break anything when dereferencing pointers.

* Parse CommonPathSuffix

Also create empty function for when we need to parse CommonNetworkRelativeLink

* Parse LocalBasePathUnicode and CommonPathSuffixUnicode

NOTE: these will need some testing before this will be production ready, as I'm making a lot of assumptions here.

* Return size of LinkInfo section

* Add StringData parsing

* Add initial code for parsing ExtraData section

Only parsing `TrackerDataBlock` at the moment, but setting up values in advance of setting up the other structures/parsers

* Add the remaining ExtraData structures

In some cases I don't make a structure where the parsing function will just handle the data (e.g. where there is variable data).

I will likely also ignore PropertyStore for now as that has separate documentation to parse it.

* More specific parsing of Droid GUIDs

* Move code out of VolumeID parsing indent

The rest of the LinkInfo section wasn't parsing unless a VolumeID was present, which shouldn't be how it works.

* Remove incorrect CommonNetworkRelativeLinkOffset setting

Also add structure for CommonNetworkRelativeLink parsing

* Implement CommonNetworkRelativeLink parsing

And add a couple of test cases for it

* Formatting

* Make LinkInfo parsing memory safe

* Remove unnecessary constant

* Make StringData parsing memory safe

Also convert `block_data_size_remaining` to `int` from `size_t`. This is because we don't want to underflow the `size_t` type, and assume we have more data left than we actually do.

* Fix up block data size remaining calculations in ExtraData

* Add more constants

* Add in overlay variable

* Make current ExtraData function memory safe

* Setup switch/case for ExtraData parsing

* ConsoleDataBlock parsing

* Add ConsoleFedData parsing

* Convert tracker data to struct and add more fields

* Add extra fields to current ExtraData structures

* Refactor structures

* Rename sample LNKs

* Refactor into parse_volume_id

* Parse DarwinData and fixed up block struct entries

* Add is_malformed entry

Checks whether a LNK has failed parsing due to it being malformed.

* Add overlay test case

* Parse EnvironmentVariableDataBlock

* Parse IconEnvironmentDataBlock

* Add KnownFolderDataBlock parsing

* Add placeholder parsing for PropertyDataStoreBlock

* Parse ShimDataBlock

* Parse SpecialFolderDataBlock

* Remove id_list_ptr var

* Refactor into its own function to parse IDList

* Parse VistaAndAboveIDListDataBlock

* Remove printf

* Refactor item_id_list into structure

* Add LinkInfoFlags as external variables

* Only process relevant link info if flags set

* Update StringData to also accept ASCII

I assumed it would only be ASCII, but the `IsUnicode` flag can help indicate what type of string it is.

* Only parse ExtraData if there is data left

* Retype to strings

* Fix environment var data parsing

I thought wchar_t was 16 bits, but turns out it can also be 32 bits... I'll need to change up other routines to take this into account as well

* Move inside if statement to prevent setting

* Fix icon env unicode issue

* Convert remaining wchar_t struct entries

* Add ExtraData test cases

* Add ExtraData tests (2)

* Make sure timestamps are UTC

* Start LNK module documentation

* Add ShowCommand constants

* Finish documenting LNK headers

* Change test to flag comparison

* Correct structure names

* Update test-lnk.c

* Document LinkInfo section

* Document StringData

* Add more constants

* Document ConsoleData

* Update lnk.rst

* Finish documenting LNK module

* Some extra comments

* Update lnk.rst

* Apply clang formatting

* Removed test for now

* Add more flags and renamed console_fe_data

* Formatting

* Update comment on PropertyStoreData

* Change variable names due to potential clashes

Changed the variables used in header files:
- Reserved1
- Reserved2
- Unused1
- Unused2

The CI/CD seems to fail with these values as a default, so I'm hoping changing them fixes things

* Change packing to address misaligned pointer error

* Add LNK module to VS Projects

* Changed `block_data_size_remaining` to `unsigned int`

Make variable `unsigned int` instead of just `int` to prevent the value being negative.

* Begin removing static of strings

Starting with the ones I can test, by dynamically allocating memory after doing the check, I'm removing the possibility of there being a buffer overflow on this data.

* Dynamically allocate `volume_id_data`

* Remove more statically typed char arrays

* Dynamically allocate unicode strings

Previously were statically set in length, now dynamically allocated

* Add clearer comment

* Add todo

* Add `yr_` prefix to necessary functions

Due to #1762, needed to add `yr_` as a prefix to functions like `set_string`

* Convert 'unsigned int' to `uint32_t`

* Make constants have consistent casing

* Add extra checks on block size remaining

I found a case where a function returned a section size that was greater than the remaining block size, which caused a crash. This patch checks each value returned to make sure the next stage doesn't fail to parse.

* Fix docs for icon_location

Add `lnk.` prefix to `icon_location` variable

* Add LNK module back in

* Correct LNK module source path

* Add lnk_utils to modules list

And update other libyara auto changes

* Add LNK module tests

* Fix up LNK test in Makefile

* Fix typo in test LNK

* Attempt to fix bazel build

* Testing to see why Bazel build fails

* Revert removing tests

It seems even one test gives the error `There were tests whose specified size is too big. Use the --test_verbose_timeout_warnings command line option to see which ones these are.`

* Include LNK module in BUILD.bazel

* Add missing deps line

* Add lnk.h to Makefile

* Add lnk.h to yara.bzl

* Add lnk_utils.h to yara.bzl

* Revert automatic changes

Change some C/header files that got automatically changed while compiling YARA to the same that they are on the main branch

* Include lnk_utils in Makefile

* Convert some console data variables to signed and update docs

Some variables in the console data section are actually signed variables. So I've converted them to `int16_t` instead of `uint16_t`, added some test cases to make sure these values are properly parsed, and added some examples in the docs.

* Fix typo for window_size_y

* Add flags for LNK module

* Add extra time tests

Add tests for access time and write time
2023-08-24 09:32:54 +02:00
Victor M. Alvarez 9274e1266c Bump version to 4.4.0. 2023-08-23 12:38:28 +02:00
Vojtěch Dvořák 734347fcae Added symbols from dotnet module to reference in docs (#1938)
There were some symbols missing in docs, although they were
implemented in dotnet module.
2023-08-23 12:23:35 +02:00
Mike Goffin 8f40272720 Add CLI flag for disabling console log printing. (#1915)
- Add CLI flag that will disable the console module from printing:
  Short: -q
  Log:   --disable-console-logs
- Update documentation with new CLI flags

Closes #1912
2023-08-18 13:29:59 +02:00
Leandro Velasco 123dd201eb Update writingmodules.rst to address the changes in the path of Makefile.am (#1922) 2023-05-17 22:01:31 +02:00
MatejKastak 67e072abcf docs: Fix typos in string module docs (#1913) 2023-04-18 11:00:28 +02:00
Wesley Shields 459f64222b Fix docs. (#1910)
It is mentioned elsewhere that you can't use nocase and xor together, but it was
left out of this paragraph.
2023-04-18 09:34:10 +02:00
Wesley Shields 784dda3002 Fix docs to remove mention of tuple for string matches. (#1909) 2023-04-12 19:12:49 +02:00
Victor M. Alvarez 48a3694723 Specify the version in which some structs were added to the yara-python API. 2023-03-31 10:23:14 +02:00
Victor M. Alvarez 7b1e482032 Address issues #1766 and #1898. 2023-03-22 09:39:43 +01:00
Wesley Shields 313ab8080a Rich version data (#1883)
* Add support for version_data in rich header.

Pull out just the version data (every other dword) into it's own string. This is
quite useful if you want to hash just the version fields of the rich header,
which makes for a more robust signature because it is now independent of the
count field.

Hashing this value is a useful signature. ;)

* Add docs for version_data.
2023-02-23 22:11:36 +01:00
Victor M. Alvarez 8b8384d15f Bump version number in documentation. 2022-12-30 11:50:52 +01:00
Vincent Thiberville f9d87c68e4 fix error handling in string.to_int() (#1842)
* fix error handling in string.to_int()

Error handling in the to_int method of the new string module was not
properly done.

- errno was not reset prior to the call to strtoll, so YR_UNDEFINED
  could be returned if a prior call failed, but not the current one.
- overflow/underflow was not properly checked, as it returns LLONG_MIN
  or LLONG_MAX and not 0.

Instead, do what is recommended in the man page for strtol:
- set errno to 0 prior to the call
- check errno after the call

* Flesh out invalid cases for string.to_int

Ensure the behavior of string.to_int is the least surprising and
consistent across all OSes:

- return an error when the string is not entirely parsed (so "10p"
  fails to parse).
- return an error when the string has no digit whatsoever (avoiding
  parsing "foo" as 0).
- remove the evaluation differences on different libc implementations.

Fixes #1843

* validate value of base in string.to_int(string, base)

There seems to be implementation differences on invalid base values,
especially with cygwin. So validate that the base has a valid value
first.
2022-12-30 11:06:34 +01:00
Wesley ShieldsandPeter Babka 0a2d31f281 Collect some open PRs for inclusion for 4.3.0 (#1835)
* Fix `pe_rva_to_offset`

* Fix: checking if RVA is inside section
* Fix: real pointer to raw data is aligned down to sector size

* Add pe.import_rva() functions.

Add pe.import_rva("foo.dll", "func1") which returns the RVA of the imported
function. Also add pe.import_rva("foo.dll", 1) which does the same but the
import is done by ordinal.

* Implement delayed import RVA and add docs.

* Add math.length()

Add a math.length() which will return the length of the sequence of bytes,
including any NULL bytes.

Fixes #1778.

* Add string module.

Move the math.to_int() functions and math.length() over to the new string
module. I decided to move the to_int() because it seems logical to convert from
a string to an integer using a string module rather than the math module.

You still use math.to_string() to convert an integer to a string, and use
string.to_int() to convert a string to an integer.

Add tests and docs for string module. Move the appropriate tests from the math
module over to the new string tests.

While here, also add the console module to the bazel build as it was apparently
missing (this is untested).

* Remove unused include.

* Add tests for https://github.com/VirusTotal/yara/pull/1561/

* Fix copyright year in string module.

Co-authored-by: Peter Babka <[email protected]>
2022-12-15 09:39:56 +01:00
Wesley Shields bb5bdae8ac Update python docs with StringMatch and StringMatchInstance objects. (#1832) 2022-12-14 22:09:56 +01:00
Wesley Shields 506352681a Add note that this feature is only in 4.3.0. (#1823) 2022-11-16 00:38:59 +01:00
Mike Wiacek 02ce7c0c40 document MAGIC alternative mgc env variable (#1813) 2022-10-26 19:45:56 +02:00
Wesley Shields 4b37e42309 Fix link in capi docs. (#1812)
Add the missing trailing backtick that was missed in the original commit for
these docs.
2022-10-24 09:18:14 +02:00
Crowface 06bbcef9eb update for new mandiant url (#1786) 2022-10-03 11:28:21 +02:00
Wesley Shields c0a2b5a6c3 Add OP_OF_FOUND_AT. (#1790)
* Add OP_OF_FOUND_AT.

Add support for "any of them at 0" constructs to the language. This allows users
to avoid using long or chains like "$a at 0 or $b at 0" and also is a nicer way
to write "for any of them: ($ at 0)".

* Add short blurb to docs about new string set at offset.
2022-09-26 09:25:34 +02:00
Wesley Shields d6fc080492 Implement text string sets. (#1787)
* Implement text string sets.

Add support for text string sets into the grammar. They look like this:

for any s in ("a", "b"): (pe.imphash() == s)

This requires changing integer_set and integer_enumeration to just be set and
enumeration, and adding a new type (YR_ENUMERATION) that tracks the type of
enumeration (integer or otherwise) and the number of items in the enumeration.

The enumeration now checks that each type of the item in the enumeration is
consistent and will cause a compiler error if they are not. For example, this is
an error:

for any s in ("a", 0): (s)

Also, fix the build when using --with-debug-verbose option as it was missing the
assert.h include.

* Add docs and adjust constants layout.
2022-09-23 12:05:46 +02:00